diff options
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/GNUmakefile | 16 | ||||
-rw-r--r-- | macosx/README | 3 | ||||
-rw-r--r-- | macosx/tkMacOSXButton.c | 38 | ||||
-rw-r--r-- | macosx/tkMacOSXClipboard.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXDefault.h | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXDialog.c | 217 | ||||
-rw-r--r-- | macosx/tkMacOSXDraw.c | 49 | ||||
-rw-r--r-- | macosx/tkMacOSXEntry.c | 23 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyEvent.c | 3 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyboard.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXMenu.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXMenubutton.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXPrivate.h | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 12 | ||||
-rw-r--r-- | macosx/tkMacOSXSubwindows.c | 26 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 67 | ||||
-rw-r--r-- | macosx/tkMacOSXXStubs.c | 49 | ||||
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 20 |
18 files changed, 289 insertions, 252 deletions
diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile index 39e5962..2263e37 100644 --- a/macosx/GNUmakefile +++ b/macosx/GNUmakefile @@ -225,22 +225,6 @@ ifeq (${EMBEDDED_BUILD},1) @rm -f "${INSTALL_ROOT}${BINDIR}/${WISH}" && \ rmdir -p "${INSTALL_ROOT}${BINDIR}" 2>&- || true else -# redo prebinding (when not building for Mac OS X 10.4 or later only) - @if [ "`echo "$${MACOSX_DEPLOYMENT_TARGET}" | \ - awk -F '10\\.' '{print int($$2)}'`" -lt 4 -a "`echo "$${CFLAGS}" | \ - awk -F '-mmacosx-version-min=10\\.' '{print int($$2)}'`" -lt 4 ]; \ - then cd ${INSTALL_ROOT}/; \ - if [ ! -d usr/lib ]; then mkdir -p usr && ln -fs /usr/lib usr/ && RM_USRLIB=1; fi; \ - if [ -n "${TK_X11}" -a ! -d usr/X11R6 ]; then mkdir -p usr && ln -fs /usr/X11R6 usr/ && RM_USRX11=1; fi; \ - if [ ! -d System ]; then ln -fs /System . && RM_SYSTEM=1; fi; \ - if [ ! -d "./${LIBDIR}/Tcl.framework" ]; then ln -fs "${TCL_FRAMEWORK_DIR}/Tcl.framework" "./${LIBDIR}"; RM_TCL=1; fi; \ - redo_prebinding -r . "./${TK_FMWK_DIR}/${PRODUCT_NAME}"; \ - if [ -z "${TK_X11}" ]; then redo_prebinding -r . "./${TK_FMWK_DIR}/Resources/Wish.app/Contents/MacOS/Wish"; \ - else redo_prebinding -r . "./${BINDIR}/${WISH}"; fi; \ - if [ -n "$${RM_USRLIB:-}" ]; then rm -f usr/lib; rmdir -p usr 2>&-; fi; \ - if [ -n "$${RM_USRX11:-}" ]; then rm -f usr/X11R6; rmdir -p usr 2>&-; fi; \ - if [ -n "$${RM_SYSTEM:-}" ]; then rm -f System; fi; \ - if [ -n "$${RM_TCL:-}" ]; then rm -f "./${LIBDIR}/Tcl.framework"; fi; fi # install wish symbolic link @ln -fs ${WISH} "${INSTALL_ROOT}${BINDIR}/${wish}" endif diff --git a/macosx/README b/macosx/README index 7df4893..6d84b3e 100644 --- a/macosx/README +++ b/macosx/README @@ -171,7 +171,8 @@ newAppearance option: "aqua", "darkaqua", or "auto". If the appearance is set to aqua or darkaqua then the window will be displayed with the corresponding appearance independent of any preferences settings. If it is set to "auto" the appearance will be determined by the preferences. This command can be -used to opt out of Dark Mode on a per-window basis. +used to opt out of Dark Mode on a per-window basis. It may be best to run the "update" command before setting the appearance property, to allow the event loop to run. + - To determine the current appearance of a window in macOS 10.14 (Mojave) and higher, one can use the command: diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 00c7c9b..8a121ee 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -457,12 +457,12 @@ DrawButtonImageAndText( int textXOffset = 0, textYOffset = 0; int width = 0, height = 0; int fullWidth = 0, fullHeight = 0; + DrawParams *dpPtr = &mbPtr->drawParams; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { return; } - DrawParams *dpPtr = &mbPtr->drawParams; pixmap = (Pixmap) Tk_WindowId(tkwin); if (butPtr->image != None) { @@ -477,10 +477,6 @@ DrawButtonImageAndText( imageHeight = height; if (mbPtr->drawinfo.state == kThemeStatePressed) { - /* - * Offset bitmaps by a bit when the button is pressed. - */ - pressed = 1; } @@ -578,11 +574,9 @@ DrawButtonImageAndText( imageXOffset, imageYOffset, 1); XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0); } - y += 1; /* Tweak to match native buttons. */ - Tk_DrawTextLayout(butPtr->display, pixmap, - dpPtr->gc, butPtr->textLayout, - x + textXOffset, y + textYOffset, 0, -1); + Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout, + x + textXOffset, y + textYOffset, 0, -1); Tk_UnderlineTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout, x + textXOffset, y + textYOffset, @@ -630,8 +624,8 @@ DrawButtonImageAndText( butPtr->textHeight, &x, &y); x += butPtr->indicatorSpace; y += 1; /* Tweak to match native buttons */ - Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, - butPtr->textLayout, x, y, 0, -1); + Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout, + x, y, 0, -1); } /* @@ -772,12 +766,15 @@ TkMacOSXDrawButton( } /* - * To avoid buttons with white text on a white background, we always - * set the state to inactive in Dark Mode. It isn't perfect but it is - * usable. Using a ttk::button would be a better choice, however. + * To avoid buttons with white text on a white background, we set the + * state to inactive in Dark Mode unless the button is pressed or is a + * -default active button. This isn't perfect but it is mostly usable. + * Using a ttk::button would be a much better choice, however. */ - if (TkMacOSXInDarkMode(butPtr->tkwin)) { + if (TkMacOSXInDarkMode(butPtr->tkwin) && + mbPtr->drawinfo.state != kThemeStatePressed && + !(mbPtr->drawinfo.adornment & kThemeAdornmentDefault)) { hiinfo.state = kThemeStateInactive; } HIThemeDrawButton(&cntrRect, &hiinfo, dc.context, @@ -1047,7 +1044,9 @@ TkMacOSXComputeButtonParams( drawinfo->adornment = kThemeAdornmentNone; if (butPtr->defaultState == DEFAULT_ACTIVE) { - drawinfo->adornment |= kThemeAdornmentDefault; + if (drawinfo->state != kThemeStatePressed) { + drawinfo->adornment |= kThemeAdornmentDefault; + } if (!mbPtr->defaultPulseHandler) { mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler( PULSE_TIMER_MSECS, PulseDefaultButtonProc, butPtr); @@ -1109,6 +1108,13 @@ TkMacOSXComputeButtonDrawParams( } else if (butPtr->type == TYPE_BUTTON && butPtr->state == STATE_ACTIVE) { dpPtr->gc = butPtr->activeTextGC; dpPtr->border = butPtr->activeBorder; + } else if ((mbPtr->drawinfo.adornment & kThemeAdornmentDefault) && + mbPtr->drawinfo.state == kThemeStateActive) { + /* + * This is a "-default active" button in the front window. + */ + + dpPtr->gc = butPtr->activeTextGC; } else { dpPtr->gc = butPtr->normalTextGC; } diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 6cbcdf6..452b32f 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -259,7 +259,7 @@ TkSelUpdateClipboard( void TkSelEventProc( Tk_Window tkwin, /* Window for which event was targeted. */ - register XEvent *eventPtr) /* X event: either SelectionClear, + XEvent *eventPtr) /* X event: either SelectionClear, * SelectionRequest, or SelectionNotify. */ { if (eventPtr->type == SelectionClear) { @@ -287,7 +287,7 @@ TkSelEventProc( void TkSelPropProc( - register XEvent *eventPtr) /* X PropertyChange event. */ + XEvent *eventPtr) /* X PropertyChange event. */ { } diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index 4cdae53..73060ef 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -54,8 +54,8 @@ #define DEF_BUTTON_ANCHOR "center" #define DEF_BUTTON_ACTIVE_BG_COLOR ACTIVE_BG #define DEF_BUTTON_ACTIVE_BG_MONO BLACK -#define DEF_BUTTON_ACTIVE_FG_COLOR ACTIVE_FG -#define DEF_CHKRAD_ACTIVE_FG_COLOR DEF_BUTTON_ACTIVE_FG_COLOR +#define DEF_BUTTON_ACTIVE_FG_COLOR WHITE +#define DEF_CHKRAD_ACTIVE_FG_COLOR ACTIVE_FG #define DEF_BUTTON_ACTIVE_FG_MONO WHITE #define DEF_BUTTON_BG_COLOR NORMAL_BG #define DEF_BUTTON_BG_MONO WHITE diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index ad952e8..d93b5e2 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -197,6 +197,18 @@ getFileURL( @implementation TKApplication(TKDialog) +- (BOOL)panel:(id)sender shouldEnableURL:(NSURL *)url { + return YES; +} + +- (void)panel:(id)sender didChangeToDirectoryURL:(NSURL *)url { +} + +- (BOOL)panel:(id)sender validateURL:(NSURL *)url error:(NSError **)outError { + *outError = nil; + return YES; +} + - (void) tkFilePanelDidEnd: (NSSavePanel *) panel returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo { @@ -324,6 +336,30 @@ getFileURL( #pragma mark - +static NSInteger showOpenSavePanel( + NSSavePanel *panel, + NSWindow *parent, + FilePanelCallbackInfo *callbackInfo) +{ + NSInteger modalReturnCode; + + if (parent && ![parent attachedSheet] && [NSApp macMinorVersion] < 15) { + [panel beginSheetModalForWindow:parent + completionHandler:^(NSInteger returnCode) { + [NSApp tkFilePanelDidEnd:panel + returnCode:returnCode + contextInfo:callbackInfo ]; + }]; + modalReturnCode = callbackInfo->cmdObj ? modalOther : + [NSApp runModalForWindow:panel]; + } else { + modalReturnCode = [panel runModal]; + [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode + contextInfo:callbackInfo]; + } + return modalReturnCode; +} + /* *---------------------------------------------------------------------- * @@ -618,6 +654,8 @@ Tk_GetOpenFileObjCmd( NSInteger modalReturnCode = modalError; BOOL parentIsKey = NO; + [openpanel setDelegate:NSApp]; + for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObjStruct(interp, objv[i], openOptionStrings, sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { @@ -679,25 +717,24 @@ Tk_GetOpenFileObjCmd( break; } } - if (title) { [openpanel setTitle:title]; /* * From OSX 10.11, the title string is silently ignored in the open - * panel. Prepend the title to the message in this case. NOTE should - * be conditional on OSX version, but -mmacosx-version-min does not - * revert this behaviour + * panel. Prepend the title to the message in this case. */ - if (message) { - NSString *fullmessage = + if ([NSApp macMinorVersion] > 10) { + if (message) { + NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@", title, message]; - [message release]; - [title release]; - message = fullmessage; - } else { - message = title; + [message release]; + [title release]; + message = fullmessage; + } else { + message = title; + } } } @@ -713,27 +750,24 @@ Tk_GetOpenFileObjCmd( } if (filterInfo.doFileTypes) { - NSView *accessoryView = [[NSView alloc] - initWithFrame:NSMakeRect(0.0, 0.0, 300, 32.0)]; NSTextField *label = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)]; + NSPopUpButton *popupButton = [[NSPopUpButton alloc] + initWithFrame:NSMakeRect(50.0, 2, 240, 22.0) pullsDown:NO]; + NSView *accessoryView = [[NSView alloc] + initWithFrame:NSMakeRect(0.0, 0.0, 300, 32.0)]; [label setEditable:NO]; [label setStringValue:@"Filter:"]; [label setBordered:NO]; [label setBezeled:NO]; [label setDrawsBackground:NO]; - - NSPopUpButton *popupButton = [[NSPopUpButton alloc] - initWithFrame:NSMakeRect(50.0, 2, 240, 22.0) pullsDown:NO]; - [popupButton addItemsWithTitles:filterInfo.fileTypeLabels]; [popupButton setAction:@selector(selectFormat:)]; - [accessoryView addSubview:label]; [accessoryView addSubview:popupButton]; - if (filterInfo.preselectFilter) { + /* * A specific filter was selected from the typevariable. Select it * and open the accessory view. @@ -746,17 +780,16 @@ Tk_GetOpenFileObjCmd( * allow all file types [openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]]; */ + [openpanel setAllowedFileTypes:filterInfo.allowedExtensions]; } else { [openpanel setAllowedFileTypes:filterInfo.allowedExtensions]; } - if (filterInfo.allowedExtensionsAllowAll) { [openpanel setAllowsOtherFileTypes:YES]; } else { [openpanel setAllowsOtherFileTypes:NO]; } - [openpanel setAccessoryView:accessoryView]; } else { /* @@ -765,51 +798,33 @@ Tk_GetOpenFileObjCmd( [openpanel setAllowsOtherFileTypes:YES]; } - if (cmdObj) { - callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } - + callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo)); callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->multiple = multiple; - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); - if (haveParentOption && parent && ![parent attachedSheet]) { - parentIsKey = [parent isKeyWindow]; - if (directory || filename) { - NSURL *fileURL = getFileURL(directory, filename); + if (directory || filename) { + NSURL *fileURL = getFileURL(directory, filename); - [openpanel setDirectoryURL:fileURL]; - } - - [openpanel beginSheetModalForWindow:parent - completionHandler:^(NSInteger returnCode) { - [NSApp tkFilePanelDidEnd:openpanel - returnCode:returnCode - contextInfo:callbackInfo ]; - }]; - modalReturnCode = cmdObj ? modalOther : - [NSApp runModalForWindow:openpanel]; + [openpanel setDirectoryURL:fileURL]; + } + if (haveParentOption) { + parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parentIsKey = parent && [parent isKeyWindow]; } else { - if (directory || filename) { - NSURL *fileURL = getFileURL(directory, filename); - - [openpanel setDirectoryURL:fileURL]; - } - - modalReturnCode = [openpanel runModal]; - [NSApp tkFilePanelDidEnd:openpanel returnCode:modalReturnCode - contextInfo:callbackInfo]; + parent = nil; + parentIsKey = False; } + modalReturnCode = showOpenSavePanel(openpanel, parent, callbackInfo); result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR; if (parentIsKey) { [parent makeKeyWindow]; } - if ((typeVariablePtr && (modalReturnCode == NSOKButton)) && filterInfo.doFileTypes) { /* @@ -833,7 +848,7 @@ Tk_GetOpenFileObjCmd( */ NSURL *selectedFile; - + NSString *extension; if (multiple) { /* * Use the first file in the case of multiple selection. @@ -844,14 +859,13 @@ Tk_GetOpenFileObjCmd( selectedFile = [openpanel URL]; } - NSString *extension = [selectedFile pathExtension]; + extension = [selectedFile pathExtension]; if (filterInfo.preselectFilter && filterCompatible(extension, filterInfo.fileTypeIndex)) { selectedFilterIndex = filterInfo.fileTypeIndex; // The preselection from the typevariable selectedFilter = [filterInfo.fileTypeNames objectAtIndex:selectedFilterIndex]; } else { - // scan the list NSUInteger i; for (i = 0; i < [filterInfo.fileTypeNames count]; i++) { @@ -867,13 +881,11 @@ Tk_GetOpenFileObjCmd( } } } - Tcl_ObjSetVar2(interp, typeVariablePtr, NULL, Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY); } - - end: + end: return result; } @@ -916,6 +928,8 @@ Tk_GetSaveFileObjCmd( NSInteger modalReturnCode = modalError; BOOL parentIsKey = NO; + [savepanel setDelegate:NSApp]; + for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObjStruct(interp, objv[i], saveOptionStrings, sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { @@ -1063,60 +1077,38 @@ Tk_GetSaveFileObjCmd( [savepanel setExtensionHidden:NO]; if (cmdObj) { - callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } + callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo)); callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->multiple = 0; - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); - if (haveParentOption && parent && ![parent attachedSheet]) { - parentIsKey = [parent isKeyWindow]; - if (directory) { - [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; - } + if (directory) { + [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; + } - /* - * Check for file name, otherwise set to empty string; crashes with - * uncaught exception if set to nil. - */ + /* + * Check for file name and set to the empty string if nil. This prevents a crash + * with an uncaught exception. + */ - if (filename) { - [savepanel setNameFieldStringValue:filename]; - } else { - [savepanel setNameFieldStringValue:@""]; - } - [savepanel beginSheetModalForWindow:parent - completionHandler:^(NSInteger returnCode) { - [NSApp tkFilePanelDidEnd:savepanel - returnCode:returnCode - contextInfo:callbackInfo]; - }]; - modalReturnCode = cmdObj ? modalOther : - [NSApp runModalForWindow:savepanel]; + if (filename) { + [savepanel setNameFieldStringValue:filename]; } else { - if (directory) { - [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; - } - - /* - * Check for file name, otherwise set to empty string; crashes with - * uncaught exception if set to nil. - */ - - if (filename) { - [savepanel setNameFieldStringValue:filename]; - } else { - [savepanel setNameFieldStringValue:@""]; - } - modalReturnCode = [savepanel runModal]; - [NSApp tkFilePanelDidEnd:savepanel returnCode:modalReturnCode - contextInfo:callbackInfo]; + [savepanel setNameFieldStringValue:@""]; } + if (haveParentOption) { + parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parentIsKey = parent && [parent isKeyWindow]; + } else { + parent = nil; + parentIsKey = False; + } + modalReturnCode = showOpenSavePanel(savepanel, parent, callbackInfo); result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR; if (parentIsKey) { [parent makeKeyWindow]; @@ -1179,6 +1171,8 @@ Tk_ChooseDirectoryObjCmd( NSInteger modalReturnCode = modalError; BOOL parentIsKey = NO; + [panel setDelegate:NSApp]; + for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObjStruct(interp, objv[i], chooseOptionStrings, sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { @@ -1234,12 +1228,12 @@ Tk_ChooseDirectoryObjCmd( [panel setCanChooseDirectories:YES]; [panel setCanCreateDirectories:!mustexist]; if (cmdObj) { - callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } + callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo)); callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->multiple = 0; @@ -1253,22 +1247,15 @@ Tk_ChooseDirectoryObjCmd( directory = @"/"; } parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); - if (haveParentOption && parent && ![parent attachedSheet]) { - parentIsKey = [parent isKeyWindow]; - [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; - [panel beginSheetModalForWindow:parent - completionHandler:^(NSInteger returnCode) { - [NSApp tkFilePanelDidEnd:panel - returnCode:returnCode - contextInfo:callbackInfo]; - }]; - modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:panel]; + [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; + if (haveParentOption) { + parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parentIsKey = parent && [parent isKeyWindow]; } else { - [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; - modalReturnCode = [panel runModal]; - [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode - contextInfo:callbackInfo]; + parent = nil; + parentIsKey = False; } + modalReturnCode = showOpenSavePanel(panel, parent, callbackInfo); result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR; if (parentIsKey) { [parent makeKeyWindow]; @@ -1537,19 +1524,19 @@ Tk_MessageBoxObjCmd( [[buttons objectAtIndex: defaultNativeButtonIndex-1] setKeyEquivalent: @"\r"]; if (cmdObj) { - callbackInfo = ckalloc(sizeof(AlertCallbackInfo)); if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } + callbackInfo = ckalloc(sizeof(AlertCallbackInfo)); callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->typeIndex = typeIndex; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { parentIsKey = [parent isKeyWindow]; -#if MAC_OS_X_VERSION_MIN_REQUIRED > 1090 +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 [alert beginSheetModalForWindow:parent completionHandler:^(NSModalResponse returnCode) { [NSApp tkAlertDidEnd:alert @@ -1563,7 +1550,7 @@ Tk_MessageBoxObjCmd( contextInfo:callbackInfo]; #endif modalReturnCode = cmdObj ? 0 : - [NSApp runModalForWindow:[alert window]]; + [alert runModal]; } else { modalReturnCode = [alert runModal]; [NSApp tkAlertDidEnd:alert returnCode:modalReturnCode diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index f985931..103a72e 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -222,7 +222,7 @@ TkMacOSXBitmapRepFromDrawableRect( *---------------------------------------------------------------------- */ -void +int XCopyArea( Display *display, /* Display. */ Drawable src, /* Source drawable. */ @@ -243,17 +243,17 @@ XCopyArea( display->request++; if (!width || !height) { - return; + return BadDrawable; } if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { TkMacOSXDbgMsg("Failed to setup drawing context."); - return; + return BadDrawable; } if (!dc.context) { TkMacOSXDbgMsg("Invalid destination drawable - no context."); - return; + return BadDrawable; } if (srcDraw->flags & TK_IS_PIXMAP) { @@ -280,6 +280,7 @@ XCopyArea( } TkMacOSXRestoreDrawingContext(&dc); + return Success; } /* @@ -300,7 +301,7 @@ XCopyArea( *---------------------------------------------------------------------- */ -void +int XCopyPlane( Display *display, /* Display. */ Drawable src, /* Source drawable. */ @@ -321,14 +322,14 @@ XCopyPlane( display->request++; if (!width || !height) { /* TkMacOSXDbgMsg("Drawing of empty area requested"); */ - return; + return BadDrawable; } if (plane != 1) { Tcl_Panic("Unexpected plane specified for XCopyPlane"); } if (srcDraw->flags & TK_IS_PIXMAP) { if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { - return; + return BadDrawable; } CGContextRef context = dc.context; @@ -401,12 +402,13 @@ XCopyPlane( "could not get a bitmap context."); } TkMacOSXRestoreDrawingContext(&dc); + return Success; } else { /* * Source drawable is a Window, not a Pixmap. */ - XCopyArea(display, src, dst, gc, src_x, src_y, width, height, + return XCopyArea(display, src, dst, gc, src_x, src_y, width, height, dest_x, dest_y); } } @@ -848,7 +850,7 @@ XDrawSegments( *---------------------------------------------------------------------- */ -void +int XFillPolygon( Display *display, /* Display. */ Drawable d, /* Draw on this. */ @@ -864,7 +866,7 @@ XFillPolygon( display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { double prevx, prevy; @@ -888,6 +890,7 @@ XFillPolygon( CGContextEOFillPath(dc.context); } TkMacOSXRestoreDrawingContext(&dc); + return Success; } /* @@ -906,7 +909,7 @@ XFillPolygon( *---------------------------------------------------------------------- */ -void +int XDrawRectangle( Display *display, /* Display. */ Drawable d, /* Draw on this. */ @@ -920,12 +923,12 @@ XDrawRectangle( int lw = gc->line_width; if (width == 0 || height == 0) { - return; + return BadDrawable; } display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { CGRect rect; @@ -937,6 +940,7 @@ XDrawRectangle( CGContextStrokeRect(dc.context, rect); } TkMacOSXRestoreDrawingContext(&dc); + return Success; } #ifdef TK_MACOSXDRAW_UNUSED @@ -1115,7 +1119,7 @@ TkMacOSXDrawSolidBorder( *---------------------------------------------------------------------- */ -void +int XDrawArc( Display *display, /* Display. */ Drawable d, /* Draw on this. */ @@ -1131,12 +1135,12 @@ XDrawArc( int lw = gc->line_width; if (width == 0 || height == 0 || angle2 == 0) { - return; + return BadDrawable; } display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { CGRect rect; @@ -1166,6 +1170,7 @@ XDrawArc( } } TkMacOSXRestoreDrawingContext(&dc); + return Success; } #ifdef TK_MACOSXDRAW_UNUSED @@ -1191,7 +1196,7 @@ XDrawArc( *---------------------------------------------------------------------- */ -void +int XDrawArcs( Display *display, Drawable d, @@ -1206,7 +1211,7 @@ XDrawArcs( display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { CGRect rect; @@ -1247,6 +1252,7 @@ XDrawArcs( } } TkMacOSXRestoreDrawingContext(&dc); + return Success; } #endif @@ -1266,7 +1272,7 @@ XDrawArcs( *---------------------------------------------------------------------- */ -void +int XFillArc( Display *display, /* Display. */ Drawable d, /* Draw on this. */ @@ -1282,12 +1288,12 @@ XFillArc( int lw = gc->line_width; if (width == 0 || height == 0 || angle2 == 0) { - return; + return BadDrawable; } display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { CGRect rect; @@ -1326,6 +1332,7 @@ XFillArc( } } TkMacOSXRestoreDrawingContext(&dc); + return Success; } #ifdef TK_MACOSXDRAW_UNUSED diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index a1c5d60..7915f6f 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -124,16 +124,17 @@ TkpDrawEntryBorderAndFocus( int incDecWidth; /* - * Temporarily change the width of the widget so that the same code can - * be used for drawing the Entry portion of the Spinbox as is used to - * draw an ordinary Entry. The width must be restored before - * returning. + * If native spinbox buttons are going to be drawn, then temporarily + * change the width of the widget so that the same code can be used + * for drawing the Entry portion of the Spinbox as is used to draw + * an ordinary Entry. The width must be restored before returning. */ oldWidth = Tk_Width(tkwin); - ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH, - &incDecWidth); - Tk_Width(tkwin) -= incDecWidth + 1; + if (ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH, + &incDecWidth) != 0) { + Tk_Width(tkwin) -= incDecWidth + 1; + } } /* @@ -186,10 +187,10 @@ TkpDrawEntryBorderAndFocus( * have to implement it. * * Results: - * 1 if it has drawn the border, 0 if not. + * 1 if it has drawn the buttons, 0 if not. * * Side effects: - * May draw the entry border into pixmap. + * May draw the buttons into pixmap. * *-------------------------------------------------------------- */ @@ -258,9 +259,9 @@ TkpDrawSpinboxButtons( */ bgGC = Tk_GCForColor(sbPtr->entry.highlightBgColorPtr, d); - rects[0].x = bounds.origin.x; + rects[0].x = Tk_Width(tkwin) - incDecWidth - 1; rects[0].y = 0; - rects[0].width = Tk_Width(tkwin); + rects[0].width = incDecWidth + 1; rects[0].height = Tk_Height(tkwin); XFillRectangles(Tk_Display(tkwin), d, bgGC, rects, 1); diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 65b7aee..f62e07c 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -572,7 +572,7 @@ XGrabKeyboard( *---------------------------------------------------------------------- */ -void +int XUngrabKeyboard( Display* display, Time time) @@ -586,6 +586,7 @@ XUngrabKeyboard( keyboardGrabNSWindow = nil; } keyboardGrabWinPtr = NULL; + return Success; } /* diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index 5899064..5c30cb3 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.c @@ -361,7 +361,7 @@ XKeycodeToKeysym( KeyCode keycode, int index) { - register Tcl_HashEntry *hPtr; + Tcl_HashEntry *hPtr; int newKeycode; UniChar newChar; diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 790b6ff..4c1ad51 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -628,6 +628,10 @@ TkpConfigureMenuEntry( &imageHeight); image = TkMacOSXGetNSImageWithBitmap(mePtr->menuPtr->display, bitmap, gc, imageWidth, imageHeight); + if (gc->foreground == defaultFg) { + // Use a semantic foreground color by default + [image setTemplate:YES]; + } } [menuItem setImage:image]; if ((!image || mePtr->compound != COMPOUND_NONE) && mePtr->labelPtr && diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 53adb01..2e2838d 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -246,7 +246,7 @@ TkpDestroyMenuButton( void TkpComputeMenuButtonGeometry(butPtr) - register TkMenuButton *butPtr; /* Widget record for menu button. */ + TkMenuButton *butPtr; /* Widget record for menu button. */ { int width, height, avgWidth, haveImage = 0, haveText = 0; int txtWidth, txtHeight; diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 60b24f6..9d121b2 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -293,6 +293,8 @@ VISIBILITY_HIDDEN @interface TKApplication(TKWindowEvent) <NSApplicationDelegate> - (void) _setupWindowNotifications; @end +@interface TKApplication(TKDialog) <NSOpenSavePanelDelegate> +@end @interface TKApplication(TKMenu) - (void)tkSetMainMenu:(TKMenu *)menu; @end diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index a189646..66619c2 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -238,9 +238,9 @@ void TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ { - register TkScrollbar *scrollPtr = clientData; + TkScrollbar *scrollPtr = clientData; MacScrollbar *msPtr = (MacScrollbar *) scrollPtr; - register Tk_Window tkwin = scrollPtr->tkwin; + Tk_Window tkwin = scrollPtr->tkwin; TkWindow *winPtr = (TkWindow *) tkwin; TkMacOSXDrawingContext dc; @@ -346,7 +346,7 @@ TkpDisplayScrollbar( extern void TkpComputeScrollbarGeometry( - register TkScrollbar *scrollPtr) + TkScrollbar *scrollPtr) /* Scrollbar whose geometry may have * changed. */ { @@ -476,7 +476,7 @@ TkpDestroyScrollbar( void TkpConfigureScrollbar( - register TkScrollbar *scrollPtr) + TkScrollbar *scrollPtr) { /* empty */ } @@ -501,7 +501,7 @@ TkpConfigureScrollbar( int TkpScrollbarPosition( - register TkScrollbar *scrollPtr, + TkScrollbar *scrollPtr, /* Scrollbar widget record. */ int x, int y) /* Coordinates within scrollPtr's window. */ { @@ -511,7 +511,7 @@ TkpScrollbarPosition( */ int length, width, tmp; - register const int inset = scrollPtr->inset; + const int inset = scrollPtr->inset; if (scrollPtr->vertical) { length = Tk_Height(scrollPtr->tkwin); diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index b660917..e851701 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -49,7 +49,7 @@ static void NotifyVisibility(TkWindow *winPtr, XEvent *eventPtr); *---------------------------------------------------------------------- */ -void +int XDestroyWindow( Display *display, /* Display. */ Window window) /* Window. */ @@ -87,7 +87,7 @@ XDestroyWindow( ckfree(macWin->toplevel); } ckfree(macWin); - return; + return Success; } if (macWin->visRgn) { CFRelease(macWin->visRgn); @@ -111,6 +111,7 @@ XDestroyWindow( if (macWin->toplevel->referenceCount == 0) { ckfree(macWin->toplevel); } + return Success; } /* @@ -130,7 +131,7 @@ XDestroyWindow( *---------------------------------------------------------------------- */ -void +int XMapWindow( Display *display, /* Display. */ Window window) /* Window. */ @@ -226,6 +227,7 @@ XMapWindow( event.xvisibility.type = VisibilityNotify; event.xvisibility.state = VisibilityUnobscured; NotifyVisibility(winPtr, &event); + return Success; } /* @@ -279,7 +281,7 @@ NotifyVisibility( *---------------------------------------------------------------------- */ -void +int XUnmapWindow( Display *display, /* Display. */ Window window) /* Window. */ @@ -332,6 +334,7 @@ XUnmapWindow( } else { [[win contentView] setNeedsDisplay:YES]; } + return Success; } /* @@ -351,7 +354,7 @@ XUnmapWindow( *---------------------------------------------------------------------- */ -void +int XResizeWindow( Display *display, /* Display. */ Window window, /* Window. */ @@ -375,6 +378,7 @@ XResizeWindow( } else { MoveResizeWindow(macWin); } + return Success; } /* @@ -394,7 +398,7 @@ XResizeWindow( *---------------------------------------------------------------------- */ -void +int XMoveResizeWindow( Display *display, /* Display. */ Window window, /* Window. */ @@ -430,6 +434,7 @@ XMoveResizeWindow( } else { MoveResizeWindow(macWin); } + return Success; } /* @@ -448,7 +453,7 @@ XMoveResizeWindow( *---------------------------------------------------------------------- */ -void +int XMoveWindow( Display *display, /* Display. */ Window window, /* Window. */ @@ -467,6 +472,7 @@ XMoveWindow( } else { MoveResizeWindow(macWin); } + return Success; } /* @@ -591,7 +597,7 @@ GenerateConfigureNotify( *---------------------------------------------------------------------- */ -void +int XRaiseWindow( Display *display, /* Display. */ Window window) /* Window. */ @@ -606,6 +612,7 @@ XRaiseWindow( * TODO: this should generate damage */ } + return Success; } #if 0 @@ -661,7 +668,7 @@ XLowerWindow( *---------------------------------------------------------------------- */ -void +int XConfigureWindow( Display *display, /* Display. */ Window w, /* Window. */ @@ -708,6 +715,7 @@ XConfigureWindow( TkGenWMMoveRequestEvent(macWin->winPtr, macWin->winPtr->changes.x, macWin->winPtr->changes.y); #endif + return Success; } /* diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index da1b002..dae6506 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1241,7 +1241,7 @@ WmAspectCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int numer1, denom1, numer2, denom2; if ((objc != 3) && (objc != 7)) { @@ -1581,7 +1581,7 @@ WmClientCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; char *argv3; int length; @@ -1637,7 +1637,7 @@ WmColormapwindowsCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; TkWindow **cmapList, *winPtr2; int i, windowObjc, gotToplevel = 0; Tcl_Obj **windowObjv, *resultObj; @@ -1726,7 +1726,7 @@ WmCommandCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int len; if ((objc != 3) && (objc != 4)) { @@ -1783,7 +1783,7 @@ WmDeiconifyCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); if (objc != 3) { @@ -1862,7 +1862,7 @@ WmFocusmodelCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "active", "passive", NULL }; enum options { @@ -1916,7 +1916,7 @@ WmForgetCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register Tk_Window frameWin = (Tk_Window) winPtr; + Tk_Window frameWin = (Tk_Window) winPtr; if (Tk_IsTopLevel(frameWin)) { MacDrawable *macWin; @@ -1982,7 +1982,7 @@ WmFrameCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; Window window; if (objc != 3) { @@ -2022,7 +2022,7 @@ WmGeometryCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); char xSign = '+', ySign = '+'; int width, height, x = wmPtr->x, y= wmPtr->y; @@ -2093,7 +2093,7 @@ WmGridCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int reqWidth, reqHeight, widthInc, heightInc; const char *errorMsg; @@ -2187,7 +2187,7 @@ WmGroupCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window tkwin2; char *argv3; int length; @@ -2251,7 +2251,7 @@ WmIconbitmapCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; Pixmap pixmap; char *str; int len; @@ -2320,7 +2320,7 @@ WmIconifyCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; @@ -2401,7 +2401,7 @@ WmIconmaskCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; Pixmap pixmap; char *argv3; @@ -2461,7 +2461,7 @@ WmIconnameCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; int length; @@ -2598,7 +2598,7 @@ WmIconpositionCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int x, y; if ((objc != 3) && (objc != 5)) { @@ -2656,7 +2656,7 @@ WmIconwindowCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window tkwin2; WmInfo *wmPtr2; @@ -2759,8 +2759,8 @@ WmManageCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register Tk_Window frameWin = (Tk_Window) winPtr; - register WmInfo *wmPtr = winPtr->wmInfoPtr; + Tk_Window frameWin = (Tk_Window) winPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; if (!Tk_IsTopLevel(frameWin)) { MacDrawable *macWin = (MacDrawable *) winPtr->window; @@ -2823,7 +2823,7 @@ WmMaxsizeCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; if ((objc != 3) && (objc != 5)) { @@ -2877,7 +2877,7 @@ WmMinsizeCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; if ((objc != 3) && (objc != 5)) { @@ -2980,7 +2980,7 @@ WmPositionfromCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "program", "user", NULL }; enum options { @@ -3046,8 +3046,8 @@ WmProtocolCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; - register ProtocolHandler *protPtr, *prevPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; + ProtocolHandler *protPtr, *prevPtr; Atom protocol; char *cmd; int cmdLength; @@ -3147,7 +3147,7 @@ WmResizableCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; UInt64 oldAttributes = wmPtr->attributes; int oldFlags = wmPtr->flags; @@ -3226,7 +3226,7 @@ WmSizefromCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "program", "user", NULL }; enum options { @@ -3418,7 +3418,7 @@ WmStateCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "normal", "iconic", "withdrawn", "zoomed", NULL }; enum options { @@ -3538,7 +3538,7 @@ WmTitleCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; char *argv3; int length; @@ -3586,7 +3586,7 @@ WmTransientCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window master; TkWindow *masterPtr, *w; WmInfo *wmPtr2; @@ -3766,7 +3766,7 @@ WmWithdrawCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -5912,6 +5912,7 @@ WmWinAppearance( #else NSString *appearance; #endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 + const char *resultString = "unrecognized"; NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); if (win) { @@ -5930,7 +5931,8 @@ WmWinAppearance( result = Tcl_NewStringObj(resultString, strlen(resultString)); } if (result == NULL) { - Tcl_Panic("Failed to read appearance name."); + NSLog(@"Failed to read appearance name; try calling update before setting the appearance of the window."); + return TCL_OK; } if (objc == 4) { int index; @@ -6518,7 +6520,7 @@ TkpGetMS(void) *---------------------------------------------------------------------- */ -void +int XSetInputFocus( Display* display, Window focus, @@ -6528,6 +6530,7 @@ XSetInputFocus( /* * Don't need to do a thing. Tk manages the focus for us. */ + return Success; } /* diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 3cd70a7..016b334 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -435,7 +435,7 @@ XGetGeometry( return 1; } -void +int XChangeProperty( Display* display, Window w, @@ -447,15 +447,17 @@ XChangeProperty( int nelements) { Debugger(); + return Success; } -void +int XSelectInput( Display* display, Window w, long event_mask) { Debugger(); + return Success; } int @@ -514,11 +516,12 @@ XSendEvent( return 0; } -void +int XClearWindow( Display* display, Window w) { + return Success; } /* @@ -530,6 +533,7 @@ XDrawPoint( int x, int y) { + return Success; } int @@ -541,6 +545,7 @@ XDrawPoints( int npoints, int mode) { + return Success; } */ @@ -559,7 +564,7 @@ XWarpPointer( return Success; } -void +int XQueryColor( Display* display, Colormap colormap, @@ -578,9 +583,10 @@ XQueryColor( d->blue = (b << 8) | b; d->flags = DoRed|DoGreen|DoBlue; d->pad = 0; + return Success; } -void +int XQueryColors( Display* display, Colormap colormap, @@ -603,6 +609,7 @@ XQueryColors( d->flags = DoRed|DoGreen|DoBlue; d->pad = 0; } + return Success; } int @@ -641,15 +648,16 @@ XGetWindowProperty( return 0; } -void +int XRefreshKeyboardMapping( XMappingEvent *x) { /* used by tkXEvent.c */ Debugger(); + return Success; } -void +int XSetIconName( Display* display, Window w, @@ -659,9 +667,10 @@ XSetIconName( * This is a no-op, no icon name for Macs. */ display->request++; + return Success; } -void +int XForceScreenSaver( Display* display, int mode) @@ -673,6 +682,7 @@ XForceScreenSaver( */ display->request++; + return Success; } int @@ -768,62 +778,69 @@ TkGetServerInfo( *---------------------------------------------------------------------- */ -void +int XChangeWindowAttributes( Display *display, Window w, unsigned long value_mask, XSetWindowAttributes *attributes) { + return Success; } -void +int XSetWindowBackground( Display *display, Window window, unsigned long value) { + return Success; } -void +int XSetWindowBackgroundPixmap( Display *display, Window w, Pixmap background_pixmap) { + return Success; } -void +int XSetWindowBorder( Display *display, Window w, unsigned long border_pixel) { + return Success; } -void +int XSetWindowBorderPixmap( Display *display, Window w, Pixmap border_pixmap) { + return Success; } -void +int XSetWindowBorderWidth( Display *display, Window w, unsigned int width) { + return Success; } -void +int XSetWindowColormap( Display *display, Window w, Colormap colormap) { Debugger(); + return Success; } Status @@ -846,7 +863,7 @@ XSetWMClientMachine( } XIC -XCreateIC(void) +XCreateIC(XIM xim, ...) { Debugger(); return (XIC) 0; diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 27f6005..ca9d294 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -105,6 +105,10 @@ static CGFloat darkSelectedGradient[8] = { 23.0 / 255, 111.0 / 255, 232.0 / 255, 1.0, 20.0 / 255, 94.0 / 255, 206.0 / 255, 1.0 }; +static CGFloat pressedPushButtonGradient[8] = { + 35.0 / 255, 123.0 / 255, 244.0 / 255, 1.0, + 30.0 / 255, 114.0 / 255, 235.0 / 255, 1.0 +}; /* * When building on systems earlier than 10.8 there is no reasonable way to @@ -152,6 +156,7 @@ static inline CGRect BoxToRect( */ static Ttk_StateTable ThemeStateTable[] = { + {kThemeStateActive, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND}, {kThemeStateUnavailable, TTK_STATE_DISABLED, 0}, {kThemeStatePressed, TTK_STATE_PRESSED, 0}, {kThemeStateInactive, TTK_STATE_BACKGROUND, 0}, @@ -647,6 +652,11 @@ static void DrawDarkButton( bounds = CGRectInset(bounds, 1, 1); if (kind == kThemePushButton && (state & TTK_STATE_PRESSED)) { GradientFillRoundedRectangle(context, bounds, 4, + pressedPushButtonGradient, 2); + } else if (kind == kThemePushButton && + (state & TTK_STATE_ALTERNATE) && + !(state & TTK_STATE_BACKGROUND)) { + GradientFillRoundedRectangle(context, bounds, 4, darkSelectedGradient, 2); } else { if (state & TTK_STATE_DISABLED) { @@ -1198,6 +1208,7 @@ static ThemeButtonParams ListHeaderParams = {kThemeListHeaderButton, kThemeMetricListHeaderHeight}; static Ttk_StateTable ButtonValueTable[] = { + {kThemeButtonOff, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND}, {kThemeButtonMixed, TTK_STATE_ALTERNATE, 0}, {kThemeButtonOn, TTK_STATE_SELECTED, 0}, {kThemeButtonOff, 0, 0} @@ -1209,11 +1220,11 @@ static Ttk_StateTable ButtonValueTable[] = { }; static Ttk_StateTable ButtonAdornmentTable[] = { + {kThemeAdornmentNone, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0}, {kThemeAdornmentDefault | kThemeAdornmentFocus, TTK_STATE_ALTERNATE | TTK_STATE_FOCUS, 0}, - {kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0}, - {kThemeAdornmentNone, TTK_STATE_ALTERNATE, 0}, {kThemeAdornmentFocus, TTK_STATE_FOCUS, 0}, + {kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0}, {kThemeAdornmentNone, 0, 0} }; @@ -1372,6 +1383,11 @@ static void ButtonElementDraw( ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); } + } else if (info.kind == kThemePushButton && + (state & TTK_STATE_PRESSED)) { + bounds.size.height += 2; + GradientFillRoundedRectangle(dc.context, bounds, 4, + pressedPushButtonGradient, 2); } else { /* |