diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2009-07-06 20:29:21 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2009-07-06 20:29:21 (GMT) |
commit | 4cb90496fafa54e8aaa26a86cbceafe3fb992320 (patch) | |
tree | 318369a6546c015a03a943a2dd4174c27c1a38d6 | |
parent | 1c1ba29d82eafab3ad9a7d2fc54a06da5ca531b6 (diff) | |
download | tk-4cb90496fafa54e8aaa26a86cbceafe3fb992320.zip tk-4cb90496fafa54e8aaa26a86cbceafe3fb992320.tar.gz tk-4cb90496fafa54e8aaa26a86cbceafe3fb992320.tar.bz2 |
More marking of files as Objective-C.
-rw-r--r-- | macosx/tkMacOSXBitmap.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXButton.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXClipboard.c | 26 | ||||
-rw-r--r-- | macosx/tkMacOSXColor.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXCursor.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXDialog.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXDraw.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXEvent.c | 7 | ||||
-rw-r--r-- | macosx/tkMacOSXFont.c | 10 | ||||
-rw-r--r-- | macosx/tkMacOSXHLEvents.c | 12 | ||||
-rw-r--r-- | macosx/tkMacOSXInit.c | 37 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyEvent.c | 10 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyboard.c | 7 | ||||
-rw-r--r-- | macosx/tkMacOSXMenubutton.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXMenus.c | 144 | ||||
-rw-r--r-- | macosx/tkMacOSXMouseEvent.c | 34 | ||||
-rw-r--r-- | macosx/tkMacOSXNotify.c | 33 | ||||
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 47 | ||||
-rw-r--r-- | macosx/tkMacOSXSubwindows.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 302 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 9 | ||||
-rw-r--r-- | macosx/tkMacOSXXStubs.c | 4 |
22 files changed, 464 insertions, 250 deletions
diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c index 62faae1..c2515d3 100644 --- a/macosx/tkMacOSXBitmap.c +++ b/macosx/tkMacOSXBitmap.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXBitmap.c,v 1.10 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXBitmap.c,v 1.11 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -449,7 +449,7 @@ end: /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index c5355e1..ab1d01e 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXButton.c,v 1.34 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXButton.c,v 1.35 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -1173,7 +1173,7 @@ ComputeUnixButtonGeometry( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index d4be8c6..333ed34 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXClipboard.c,v 1.15 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXClipboard.c,v 1.16 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -22,8 +22,10 @@ static Tk_Window clipboardOwner = NULL; #pragma mark TKApplication(TKClipboard) @implementation TKApplication(TKClipboard) -- (void)tkProvidePasteboard:(TkDisplay *)dispPtr - pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type { +- (void) tkProvidePasteboard: (TkDisplay *) dispPtr + pasteboard: (NSPasteboard *) sender + provideDataForType: (NSString *) type +{ NSMutableString *string = [NSMutableString new]; if (dispPtr && dispPtr->clipboardActive && @@ -37,6 +39,7 @@ static Tk_Window clipboardOwner = NULL; NSString *s = [[NSString alloc] initWithBytesNoCopy: cbPtr->buffer length:cbPtr->length encoding:NSUTF8StringEncoding freeWhenDone:NO]; + [string appendString:s]; [s release]; } @@ -47,18 +50,25 @@ static Tk_Window clipboardOwner = NULL; [sender setString:string forType:type]; [string release]; } -- (void)tkProvidePasteboard:(TkDisplay *)dispPtr { + +- (void) tkProvidePasteboard: (TkDisplay *) dispPtr +{ if (dispPtr && dispPtr->clipboardActive) { [self tkProvidePasteboard:dispPtr pasteboard:[NSPasteboard generalPasteboard] provideDataForType:NSStringPboardType]; } } -- (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type { + +- (void) pasteboard: (NSPasteboard *) sender + provideDataForType: (NSString *) type +{ [self tkProvidePasteboard:TkGetDisplayList() pasteboard:sender provideDataForType:type]; } -- (void)tkCheckPasteboard { + +- (void) tkCheckPasteboard +{ if (clipboardOwner && [[NSPasteboard generalPasteboard] changeCount] != changeCount) { TkDisplay *dispPtr = TkGetDisplayList(); @@ -166,6 +176,7 @@ XSetSelectionOwner( clipboardOwner = owner ? Tk_IdToWindow(display, owner) : NULL; if (!dispPtr->clipboardActive) { NSPasteboard *pb = [NSPasteboard generalPasteboard]; + changeCount = [pb declareTypes:[NSArray array] owner:NSApp]; } } @@ -221,6 +232,7 @@ TkSelUpdateClipboard( /* Info about the content. */ { NSPasteboard *pb = [NSPasteboard generalPasteboard]; + changeCount = [pb addTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp]; } @@ -300,7 +312,7 @@ TkSuspendClipboard(void) /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 1d20553..b5a4a87 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXColor.c,v 1.16 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXColor.c,v 1.17 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -723,7 +723,7 @@ XFreeColors( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXCursor.c b/macosx/tkMacOSXCursor.c index fecfc36..1312fbd 100644 --- a/macosx/tkMacOSXCursor.c +++ b/macosx/tkMacOSXCursor.c @@ -10,7 +10,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.15 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXCursor.c,v 1.16 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -586,7 +586,7 @@ Tk_MacOSXTkOwnsCursor( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 1244a4a..196d755 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.45 2009/07/06 15:45:54 dkf Exp $ + * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.46 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -134,7 +134,7 @@ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = { #pragma mark TKApplication(TKDialog) @interface NSColorPanel(TKDialog) -- (void)_setUseModalAppearance:(BOOL)flag; +- (void) _setUseModalAppearance: (BOOL) flag; @end @implementation TKApplication(TKDialog) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 59df566..074ae0a 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.34 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.35 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -1995,7 +1995,7 @@ TkpDrawFrame( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index e22d333..37d4efe 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.26 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.27 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -25,7 +25,8 @@ enum { @implementation TKApplication(TKEvent) /* TODO: replace by +[addLocalMonitorForEventsMatchingMask ? */ -- (NSEvent *)tkProcessEvent:(NSEvent *)theEvent { +- (NSEvent *) tkProcessEvent: (NSEvent *) theEvent +{ #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif @@ -148,7 +149,7 @@ TkMacOSXFlushWindows(void) /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index f6d34c9..dc03c70 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXFont.c,v 1.45 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXFont.c,v 1.46 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -93,9 +93,9 @@ static void DrawCharsInContext(Display *display, Drawable drawable, GC gc, int rangeLength, int x, int y, double angle); @interface NSFont(TKFont) -- (NSFont *)bestMatchingFontForCharacters:(const UTF16Char *)characters - length:(NSUInteger)length attributes:(NSDictionary *)attributes - actualCoveredLength:(NSUInteger *)coveredLength; +- (NSFont *) bestMatchingFontForCharacters: (const UTF16Char *) characters + length: (NSUInteger) length attributes: (NSDictionary *) attributes + actualCoveredLength: (NSUInteger *) coveredLength; @end #pragma mark - @@ -1278,7 +1278,7 @@ TkMacOSXUseAntialiasedText( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index 841a04a..9fee118 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXHLEvents.c,v 1.20 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXHLEvents.c,v 1.21 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -53,15 +53,15 @@ static OSStatus FSRefToDString(const FSRef *fsref, Tcl_DString *ds); #pragma mark TKApplication(TKHLEvents) @implementation TKApplication(TKHLEvents) - -- (void)terminate:(id)sender { +- (void) terminate: (id) sender +{ QuitHandler(NULL, NULL, (SRefCon) _eventInterp); } -- (void)preferences:(id)sender { +- (void) preferences: (id) sender +{ PrefsHandler(NULL, NULL, (SRefCon) _eventInterp); } - @end #pragma mark - @@ -718,7 +718,7 @@ FSRefToDString( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index f795569..e3d78ce 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInit.c,v 1.40 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.41 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -43,7 +43,7 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt #endif @interface TKApplication(TKKeyboard) -- (void)keyboardChanged:(NSNotification *)notification; +- (void) keyboardChanged: (NSNotification *) notification; @end #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 @@ -52,15 +52,15 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt #define TKApplication_NSApplicationDelegate #endif @interface TKApplication(TKWindowEvent) TKApplication_NSApplicationDelegate -- (void)_setupWindowNotifications; +- (void) _setupWindowNotifications; @end @interface TKApplication(TKScrlbr) -- (void)_setupScrollBarNotifications; +- (void) _setupScrollBarNotifications; @end @interface TKApplication(TKMenus) -- (void)_setupMenus; +- (void) _setupMenus; @end @implementation TKApplication @@ -68,13 +68,17 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt @implementation TKApplication(TKInit) #ifdef TK_MAC_DEBUG_NOTIFICATIONS -- (void)_postedNotification:(NSNotification *)notification { +- (void) _postedNotification: (NSNotification *) notification +{ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); } #endif -- (void)_setupApplicationNotifications { + +- (void) _setupApplicationNotifications +{ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; -#define observe(n, s) [nc addObserver:self selector:@selector(s) name:(n) object:nil] +#define observe(n, s) \ + [nc addObserver:self selector:@selector(s) name:(n) object:nil] observe(NSApplicationDidBecomeActiveNotification, applicationActivate:); observe(NSApplicationDidResignActiveNotification, applicationDeactivate:); observe(NSApplicationDidUnhideNotification, applicationShowHide:); @@ -86,7 +90,9 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &keyboardChanged, kTISNotifySelectedKeyboardInputSourceChanged, NULL, CFNotificationSuspensionBehaviorCoalesce); #endif } -- (void)_setupEventLoop { + +- (void) _setupEventLoop +{ _running = 1; if (!_appFlags._hasBeenRun) { _appFlags._hasBeenRun = YES; @@ -94,7 +100,9 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt } [self setWindowsNeedUpdate:YES]; } -- (void)_setup:(Tcl_Interp *)interp { + +- (void) _setup: (Tcl_Interp *) interp +{ _eventInterp = interp; _defaultMainMenu = nil; [self _setupMenus]; @@ -107,8 +115,11 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt [self _setupScrollBarNotifications]; [self _setupApplicationNotifications]; } -- (NSString *)tkFrameworkImagePath:(NSString*)image { + +- (NSString *) tkFrameworkImagePath: (NSString *) image +{ NSString *path = nil; + if (tkLibPath[0] != '\0') { path = [[NSBundle bundleWithPath:[[NSString stringWithUTF8String: tkLibPath] stringByAppendingString:@"/../.."]] @@ -117,8 +128,10 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt if (!path) { const char *tk_library = Tcl_GetVar2(_eventInterp, "tk_library", NULL, TCL_GLOBAL_ONLY); + if (tk_library) { NSFileManager *fm = [NSFileManager defaultManager]; + path = [[NSString stringWithUTF8String:tk_library] stringByAppendingFormat:@"/%@", image]; if (![fm isReadableFileAtPath:path]) { @@ -577,7 +590,7 @@ TkMacOSXGetStringObjFromCFString( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 6e16583..6d4a367 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.27 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.28 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -31,7 +31,8 @@ static NSModalSession modalSession = NULL; #pragma mark TKApplication(TKKeyEvent) @implementation TKApplication(TKKeyEvent) -- (NSEvent *)tkProcessKeyEvent:(NSEvent *)theEvent { +- (NSEvent *) tkProcessKeyEvent: (NSEvent *) theEvent +{ #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif @@ -43,7 +44,6 @@ static NSModalSession modalSession = NULL; NSString *characters = nil, *charactersIgnoringModifiers = nil; static NSUInteger savedModifiers = 0; - switch (type) { case NSKeyUp: case NSKeyDown: @@ -61,7 +61,6 @@ static NSModalSession modalSession = NULL; default: return theEvent; - break; } unsigned int state = 0; @@ -107,6 +106,7 @@ static NSModalSession modalSession = NULL; } XEvent xEvent; + xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); xEvent.xany.send_event = false; xEvent.xany.display = Tk_Display(tkwin); @@ -343,7 +343,7 @@ Tk_SetCaretPos( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index 534cb11..e02b3cd 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXKeyboard.c,v 1.25 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXKeyboard.c,v 1.26 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -122,7 +122,8 @@ static int KeycodeToUnicode(UniChar * uniChars, int maxChars, #pragma mark TKApplication(TKKeyboard) @implementation TKApplication(TKKeyboard) -- (void)keyboardChanged:(NSNotification *)notification { +- (void) keyboardChanged: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif @@ -906,7 +907,7 @@ TkpInitKeymapInfo( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index bca4c9e..e17d452 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenubutton.c,v 1.21 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenubutton.c,v 1.22 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -468,7 +468,7 @@ MenuButtonEventProc( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index da15e0a..0299ce0 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.25 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.26 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -18,24 +18,29 @@ static void GenerateEditEvent(const char *name); static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); - + #pragma mark TKApplication(TKMenus) @implementation TKApplication(TKMenus) -- (void)_setupMenus { +- (void) _setupMenus +{ if (_defaultMainMenu) { return; } TkMenuInit(); + NSString *applicationName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]; + if (!applicationName) { applicationName = [[NSProcessInfo processInfo] processName]; } + NSString *aboutName = (applicationName && ![applicationName isEqualToString:@"Wish"] && ![applicationName hasPrefix:@"tclsh"]) ? applicationName : @"Tcl & Tk"; + _servicesMenu = [NSMenu menuWithTitle:@"Services"]; _defaultApplicationMenuItems = [[NSArray arrayWithObjects: [NSMenuItem separatorItem], @@ -65,6 +70,7 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); [NSMenuItem itemWithTitle: [NSString stringWithFormat:@"About %@", aboutName] action:@selector(orderFrontStandardAboutPanel:)] atIndex:0]; + TKMenu *fileMenu = [TKMenu menuWithTitle:@"File" menuItems: [NSArray arrayWithObjects: [NSMenuItem itemWithTitle: @@ -91,6 +97,7 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); [NSMenuItem itemWithTitle:@"Delete" action:@selector(delete:) target:nil], nil]]; + _defaultWindowsMenuItems = [[NSArray arrayWithObjects: [NSMenuItem itemWithTitle:@"Minimize" action:@selector(performMiniaturize:) target:nil @@ -101,15 +108,19 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); [NSMenuItem itemWithTitle:@"Bring All to Front" action:@selector(arrangeInFront:)], nil] retain]; + TKMenu *windowsMenu = [TKMenu menuWithTitle:@"Window" menuItems: _defaultWindowsMenuItems]; + _defaultHelpMenuItems = [[NSArray arrayWithObjects: [NSMenuItem itemWithTitle: [NSString stringWithFormat:@"%@ Help", applicationName] action:@selector(showHelp:) keyEquivalent:@"?"], nil] retain]; + TKMenu *helpMenu = [TKMenu menuWithTitle:@"Help" menuItems: _defaultHelpMenuItems]; + [self setServicesMenu:_servicesMenu]; [self setWindowsMenu:windowsMenu]; _defaultMainMenu = [[TKMenu menuWithTitle:@"" submenus:[NSArray @@ -121,22 +132,28 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); [helpMenu setSpecial:tkHelpMenu]; [self tkSetMainMenu:nil]; } -- (void)dealloc { + +- (void) dealloc +{ [_defaultMainMenu release]; [_defaultHelpMenuItems release]; [_defaultWindowsMenuItems release]; [_defaultApplicationMenuItems release]; [super dealloc]; } -- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { + +- (BOOL) validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>) anItem +{ SEL action = [anItem action]; if (sel_isEqual(action, @selector(preferences:))) { Tcl_CmdInfo dummy; + return (_eventInterp && Tcl_GetCommandInfo(_eventInterp, "::tk::mac::ShowPreferences", &dummy)); } else if (sel_isEqual(action, @selector(tkDemo:))) { BOOL haveDemo = NO; + if (_eventInterp) { Tcl_Obj *path = GetWidgetDemoPath(_eventInterp); @@ -151,45 +168,58 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); return [super validateUserInterfaceItem:anItem]; } } -- (void)orderFrontStandardAboutPanel:(id)sender { + +- (void) orderFrontStandardAboutPanel: (id) sender +{ Tcl_CmdInfo dummy; + if (!_eventInterp || !Tcl_GetCommandInfo(_eventInterp, "tkAboutDialog", &dummy) || (GetCurrentEventKeyModifiers() & optionKey)) { TkAboutDlg(); } else { int code = Tcl_EvalEx(_eventInterp, "tkAboutDialog", -1, TCL_EVAL_GLOBAL); + if (code != TCL_OK) { Tcl_BackgroundException(_eventInterp, code); } Tcl_ResetResult(_eventInterp); } } -- (void)showHelp:(id)sender { + +- (void) showHelp: (id) sender +{ Tcl_CmdInfo dummy; + if (!_eventInterp || !Tcl_GetCommandInfo(_eventInterp, "::tk::mac::ShowHelp", &dummy)) { [super showHelp:sender]; } else { int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ShowHelp", -1, TCL_EVAL_GLOBAL); + if (code != TCL_OK) { Tcl_BackgroundException(_eventInterp, code); } Tcl_ResetResult(_eventInterp); } } -- (void)tkSource:(id)sender { + +- (void) tkSource: (id) sender +{ if (_eventInterp) { if (Tcl_EvalEx(_eventInterp, "tk_getOpenFile -filetypes {" "{{TCL Scripts} {.tcl} TEXT} {{Text Files} {} TEXT}}", -1, TCL_EVAL_GLOBAL) == TCL_OK) { Tcl_Obj *path = Tcl_GetObjResult(_eventInterp); int len; + Tcl_GetStringFromObj(path, &len); if (len) { Tcl_IncrRefCount(path); + int code = Tcl_FSEvalFile(_eventInterp, path); + if (code != TCL_OK) { Tcl_BackgroundException(_eventInterp, code); } @@ -199,12 +229,17 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); Tcl_ResetResult(_eventInterp); } } -- (void)tkDemo:(id)sender { + +- (void) tkDemo: (id) sender +{ if (_eventInterp) { Tcl_Obj *path = GetWidgetDemoPath(_eventInterp); + if (path) { Tcl_IncrRefCount(path); + int code = Tcl_FSEvalFile(_eventInterp, path); + if (code != TCL_OK) { Tcl_BackgroundException(_eventInterp, code); } @@ -214,15 +249,19 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); } } @end - + #pragma mark TKContentView(TKMenus) @implementation TKContentView(TKMenus) -- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { + +- (BOOL) validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>) anItem +{ return YES; } + #define EDIT_ACTION(a, e) \ - - (void) a:(id)sender { \ + - (void) a: (id) sender \ + { \ if ([sender isKindOfClass:[NSMenuItem class]]) { \ GenerateEditEvent(#e); \ } \ @@ -373,90 +412,129 @@ GenerateEditEvent( } #pragma mark - + #pragma mark NSMenu & NSMenuItem Utilities @implementation NSMenu(TKUtils) -+ (id)menuWithTitle:(NSString *)title { + ++ (id) menuWithTitle: (NSString *) title +{ NSMenu *m = [[self alloc] initWithTitle:title]; + return [m autorelease]; } -+ (id)menuWithTitle:(NSString *)title menuItems:(NSArray *)items { + ++ (id) menuWithTitle: (NSString *) title menuItems: (NSArray *) items +{ NSMenu *m = [[self alloc] initWithTitle:title]; + for (NSMenuItem *i in items) { [m addItem:i]; } return [m autorelease]; } -+ (id)menuWithTitle:(NSString *)title submenus:(NSArray *)submenus { + ++ (id) menuWithTitle: (NSString *) title submenus: (NSArray *) submenus +{ NSMenu *m = [[self alloc] initWithTitle:title]; + for (NSMenu *i in submenus) { [m addItem:[NSMenuItem itemWithSubmenu:i]]; } return [m autorelease]; } -- (NSMenuItem *)itemWithSubmenu:(NSMenu *)submenu { + +- (NSMenuItem *) itemWithSubmenu: (NSMenu *) submenu +{ return [self itemAtIndex:[self indexOfItemWithSubmenu:submenu]]; } -- (NSMenuItem *)itemInSupermenu { + +- (NSMenuItem *) itemInSupermenu +{ NSMenu *supermenu = [self supermenu]; + return (supermenu ? [supermenu itemWithSubmenu:self] : nil); } @end @implementation NSMenuItem(TKUtils) -+ (id)itemWithSubmenu:(NSMenu *)submenu { + ++ (id) itemWithSubmenu: (NSMenu *) submenu +{ NSMenuItem *i = [[self alloc] initWithTitle:[submenu title] action:NULL keyEquivalent:@""]; + [i setSubmenu:submenu]; return [i autorelease]; } -+ (id)itemWithTitle:(NSString *)title submenu:(NSMenu *)submenu { + ++ (id) itemWithTitle: (NSString *) title submenu: (NSMenu *) submenu +{ NSMenuItem *i = [[self alloc] initWithTitle:title action:NULL keyEquivalent:@""]; + [i setSubmenu:submenu]; return [i autorelease]; } -+ (id)itemWithTitle:(NSString *)title action:(SEL)action { + ++ (id) itemWithTitle: (NSString *) title action: (SEL) action +{ NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:@""]; + [i setTarget:NSApp]; return [i autorelease]; } -+ (id)itemWithTitle:(NSString *)title action:(SEL)action - target:(id)target { + ++ (id) itemWithTitle: (NSString *) title action: (SEL) action + target: (id) target +{ NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:@""]; + [i setTarget:target]; return [i autorelease]; } -+ (id)itemWithTitle:(NSString *)title action:(SEL)action - keyEquivalent:(NSString *)keyEquivalent { + ++ (id) itemWithTitle: (NSString *) title action: (SEL) action + keyEquivalent: (NSString *) keyEquivalent +{ NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:keyEquivalent]; + [i setTarget:NSApp]; return [i autorelease]; } -+ (id)itemWithTitle:(NSString *)title action:(SEL)action - target:(id)target keyEquivalent:(NSString *)keyEquivalent { + ++ (id) itemWithTitle: (NSString *) title action: (SEL) action + target: (id) target keyEquivalent: (NSString *) keyEquivalent +{ NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:keyEquivalent]; + [i setTarget:target]; return [i autorelease]; } -+ (id)itemWithTitle:(NSString *)title action:(SEL)action - keyEquivalent:(NSString *)keyEquivalent - keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask { + ++ (id) itemWithTitle: (NSString *) title action: (SEL) action + keyEquivalent: (NSString *) keyEquivalent + keyEquivalentModifierMask: (NSUInteger) keyEquivalentModifierMask +{ NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:keyEquivalent]; + [i setTarget:NSApp]; [i setKeyEquivalentModifierMask:keyEquivalentModifierMask]; return [i autorelease]; } -+ (id)itemWithTitle:(NSString *)title action:(SEL)action - target:(id)target keyEquivalent:(NSString *)keyEquivalent - keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask { + ++ (id) itemWithTitle: (NSString *) title action: (SEL) action + target: (id) target keyEquivalent: (NSString *) keyEquivalent + keyEquivalentModifierMask: (NSUInteger) keyEquivalentModifierMask +{ NSMenuItem *i = [[self alloc] initWithTitle:title action:action keyEquivalent:keyEquivalent]; + [i setTarget:target]; [i setKeyEquivalentModifierMask:keyEquivalentModifierMask]; return [i autorelease]; @@ -465,7 +543,7 @@ GenerateEditEvent( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index a910447..06b35b2 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.36 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.37 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -37,7 +37,8 @@ enum { }; @implementation TKApplication(TKMouseEvent) -- (NSEvent *)tkProcessMouseEvent:(NSEvent *)theEvent { +- (NSEvent *) tkProcessMouseEvent: (NSEvent *) theEvent +{ #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif @@ -89,6 +90,7 @@ enum { } NSPoint global, local = [theEvent locationInWindow]; + if (win) { global = [win convertBaseToScreen:local]; local.y = [win frame].size.height - local.y; @@ -128,23 +130,23 @@ enum { 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) { - switch (type) { - case NSLeftMouseDown: - case NSRightMouseDown: - case NSLeftMouseDragged: - case NSRightMouseDragged: - case NSOtherMouseDown: - state |= 1 << (button + 8); - break; - default: - break; - } + } else if (button < 5) { + switch (type) { + case NSLeftMouseDown: + case NSRightMouseDown: + case NSLeftMouseDragged: + case NSRightMouseDragged: + case NSOtherMouseDown: + state |= 1 << (button + 8); + break; + default: + break; } } + NSUInteger modifiers = [theEvent modifierFlags]; if (modifiers & NSAlphaShiftKeyMask) { @@ -537,7 +539,7 @@ GenerateButtonEvent( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index c186342..ddc32df 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXNotify.c,v 1.22 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXNotify.c,v 1.23 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -26,8 +26,8 @@ typedef struct ThreadSpecificData { } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; -#define TSD_INIT() ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, \ - sizeof(ThreadSpecificData)) +#define TSD_INIT() ThreadSpecificData *tsdPtr = \ + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)) static void TkMacOSXNotifyExitHandler(ClientData clientData); static void TkMacOSXEventsSetupProc(ClientData clientData, int flags); @@ -36,11 +36,12 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); #pragma mark TKApplication(TKNotify) @interface NSApplication(TKNotify) -- (void)_modalSession:(NSModalSession)session sendEvent:(NSEvent *)event; +- (void) _modalSession: (NSModalSession) session sendEvent: (NSEvent *) event; @end @implementation NSWindow(TKNotify) -- (id)tkDisplayIfNeeded { +- (id) tkDisplayIfNeeded +{ if (![self isAutodisplay]) { [self displayIfNeeded]; } @@ -49,14 +50,18 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); @end @implementation TKApplication(TKNotify) -- (NSEvent *)nextEventMatchingMask:(NSUInteger)mask - untilDate:(NSDate *)expiration inMode:(NSString *)mode - dequeue:(BOOL)deqFlag { +- (NSEvent *) nextEventMatchingMask: (NSUInteger) mask + untilDate: (NSDate *) expiration inMode: (NSString *) mode + dequeue: (BOOL) deqFlag +{ NSAutoreleasePool *pool = [NSAutoreleasePool new]; + [NSApp makeWindowsPerform:@selector(tkDisplayIfNeeded) inOrder:NO]; + int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); NSEvent *event = [[super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue:deqFlag] retain]; + Tcl_SetServiceMode(oldMode); if (event) { TSD_INIT(); @@ -70,9 +75,12 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); [pool drain]; return [event autorelease]; } -- (void)sendEvent:(NSEvent *)theEvent { + +- (void) sendEvent: (NSEvent *) theEvent +{ TSD_INIT(); int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); + tsdPtr->sendEventNestingLevel++; [super sendEvent:theEvent]; tsdPtr->sendEventNestingLevel--; @@ -137,6 +145,7 @@ void Tk_MacOSXSetupTkNotifier(void) { TSD_INIT(); + if (!tsdPtr->initialized) { tsdPtr->initialized = 1; @@ -185,6 +194,7 @@ TkMacOSXNotifyExitHandler( ClientData clientData) /* Not used. */ { TSD_INIT(); + Tcl_DeleteEventSource(TkMacOSXEventsSetupProc, TkMacOSXEventsCheckProc, GetMainEventQueue()); tsdPtr->initialized = 0; @@ -217,13 +227,14 @@ TkMacOSXEventsSetupProc( if (flags & TCL_WINDOW_EVENTS && ![[NSRunLoop currentRunLoop] currentMode]) { static const Tcl_Time zeroBlockTime = { 0, 0 }; - TSD_INIT(); + if (!tsdPtr->currentEvent) { NSEvent *currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(TkMacOSXGetModalSession()) dequeue:YES]; + if (currentEvent) { tsdPtr->currentEvent = TkMacOSXMakeUncollectableAndRetain(currentEvent); @@ -306,7 +317,7 @@ TkMacOSXEventsCheckProc( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 411e18d..2b1a74e 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.30 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.31 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -66,13 +66,14 @@ static void ScrollbarEventProc(ClientData clientData, Tk_ClassProcs tkpScrollbarProcs = { sizeof(Tk_ClassProcs) /* size */ }; - + #pragma mark TKApplication(TKScrlbr) #define NSAppleAquaScrollBarVariantChanged @"AppleAquaScrollBarVariantChanged" @implementation TKApplication(TKScrlbr) -- (void)tkScroller:(NSScroller *)scroller { +- (void) tkScroller: (NSScroller *) scroller +{ NSScrollerPart hitPart = [scroller hitPart]; TkScrollbar *scrollPtr = (TkScrollbar *)[scroller tag]; Tcl_DString cmdString; @@ -131,14 +132,19 @@ Tk_ClassProcs tkpScrollbarProcs = { [scroller knobProportion]); #endif } -- (void)scrollBarVariantChanged:(NSNotification *)notification { + +- (void) scrollBarVariantChanged: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif UpdateScrollbarMetrics(); } -- (void)_setupScrollBarNotifications { + +- (void) _setupScrollBarNotifications +{ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + #define observe(n, s) [nc addObserver:self selector:@selector(s) name:(n) object:nil] observe(NSAppleAquaScrollBarVariantChanged, scrollBarVariantChanged:); #undef observe @@ -235,11 +241,8 @@ TkpCreateScrollbar( MacScrollbar *scrollPtr = (MacScrollbar *) ckalloc(sizeof(MacScrollbar)); scrollPtr->scroller = nil; - - Tk_CreateEventHandler(tkwin, ActivateMask|ExposureMask| - StructureNotifyMask|FocusChangeMask, - ScrollbarEventProc, (ClientData) scrollPtr); - + Tk_CreateEventHandler(tkwin, StructureNotifyMask|FocusChangeMask| + ActivateMask|ExposureMask, ScrollbarEventProc, scrollPtr); return (TkScrollbar *) scrollPtr; } @@ -274,8 +277,8 @@ TkpDestroyScrollbar( * TkpDisplayScrollbar -- * * This procedure redraws the contents of a scrollbar window. It is - * invoked as a do-when-idle handler, so it only runs when there's - * nothing else for the application to do. + * invoked as a do-when-idle handler, so it only runs when there's nothing + * else for the application to do. * * Results: * None. @@ -290,8 +293,8 @@ void TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ { - TkScrollbar *scrollPtr = (TkScrollbar *) clientData; - MacScrollbar *macScrollPtr = (MacScrollbar *) clientData; + TkScrollbar *scrollPtr = clientData; + MacScrollbar *macScrollPtr = clientData; NSScroller *scroller = macScrollPtr->scroller; Tk_Window tkwin = scrollPtr->tkwin; TkWindow *winPtr = (TkWindow *) tkwin; @@ -338,12 +341,16 @@ TkpDisplayScrollbar( Tk_Height(tkwin)); frame = NSInsetRect(frame, scrollPtr->inset, scrollPtr->inset); frame.origin.y = viewHeight - (frame.origin.y + frame.size.height); + NSWindow *w = [view window]; + if ([w showsResizeIndicator]) { NSRect growBox = [view convertRect:[w _growBoxRect] fromView:nil]; + if (NSIntersectsRect(growBox, frame)) { if (scrollPtr->vertical) { CGFloat y = frame.origin.y; + frame.origin.y = growBox.origin.y + growBox.size.height; frame.size.height -= frame.origin.y - y; } else { @@ -408,8 +415,12 @@ TkpComputeScrollbarGeometry( macScrollPtr->variant = variant; if (scroller) { NSSize size = [scroller frame].size; + if ((size.width > size.height) ^ !scrollPtr->vertical) { - /* Orientation changed, need new scroller */ + /* + * Orientation changed, need new scroller. + */ + if ([scroller superview]) { [scroller removeFromSuperviewWithoutNeedingDisplay]; } @@ -597,7 +608,7 @@ ScrollbarEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { - TkScrollbar *scrollPtr = (TkScrollbar *) clientData; + TkScrollbar *scrollPtr = clientData; switch (eventPtr->type) { case UnmapNotify: @@ -605,7 +616,7 @@ ScrollbarEventProc( break; case ActivateNotify: case DeactivateNotify: - TkScrollbarEventuallyRedraw((ClientData) scrollPtr); + TkScrollbarEventuallyRedraw(scrollPtr); break; default: TkScrollbarEventProc(clientData, eventPtr); @@ -614,7 +625,7 @@ ScrollbarEventProc( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 9b01178..0f13aae 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.30 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.31 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -1344,7 +1344,7 @@ Tk_FreePixmap( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index d9d4429..91fed49 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.36 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.37 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -47,13 +47,16 @@ extern NSString *NSWindowDidOrderOffScreenNotification; #define NSWindowDidEndLiveResizeNotification @"NSWindowDidEndLiveResizeNotification" #endif #endif - + @implementation TKApplication(TKWindowEvent) -- (void)windowActivation:(NSNotification *)notification { + +- (void) windowActivation: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif - BOOL activate = [[notification name] isEqualToString:NSWindowDidBecomeKeyNotification]; + BOOL activate = [[notification name] + isEqualToString:NSWindowDidBecomeKeyNotification]; NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); @@ -61,14 +64,19 @@ extern NSString *NSWindowDidOrderOffScreenNotification; GenerateActivateEvents(winPtr, activate); } } -- (void)windowBoundsChanged:(NSNotification *)notification { + +- (void) windowBoundsChanged: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif - BOOL movedOnly = [[notification name] isEqualToString:NSWindowDidMoveNotification]; + BOOL movedOnly = [[notification name] + isEqualToString:NSWindowDidMoveNotification]; + if (movedOnly) { /* constraining to screen after move not needed with AppKit */ } + NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); @@ -91,13 +99,18 @@ extern NSString *NSWindowDidOrderOffScreenNotification; flags |= TK_SIZE_CHANGED; } if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) { - /* propagate geometry changes immediately */ + /* + * Propagate geometry changes immediately. + */ + flags |= TK_MACOSX_HANDLE_EVENT_IMMEDIATELY; } TkGenWMConfigureEvent((Tk_Window) winPtr, x, y, width, height, flags); } } -- (void)windowExpanded:(NSNotification *)notification { + +- (void) windowExpanded: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif @@ -109,7 +122,10 @@ extern NSString *NSWindowDidOrderOffScreenNotification; TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState; Tk_MapWindow((Tk_Window) winPtr); if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) { - /* Process all Tk events generated by Tk_MapWindow() */ + /* + * Process all Tk events generated by Tk_MapWindow(). + */ + while (Tcl_ServiceEvent(0)) {} while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} @@ -124,7 +140,9 @@ extern NSString *NSWindowDidOrderOffScreenNotification; } } } -- (void)windowCollapsed:(NSNotification *)notification { + +- (void) windowCollapsed: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif @@ -135,7 +153,9 @@ extern NSString *NSWindowDidOrderOffScreenNotification; Tk_UnmapWindow((Tk_Window) winPtr); } } -- (void)windowClosed:(NSNotification *)notification { + +- (void) windowClosed: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif @@ -146,15 +166,22 @@ extern NSString *NSWindowDidOrderOffScreenNotification; TkGenWMDestroyEvent((Tk_Window) winPtr); } } + #ifdef TK_MAC_DEBUG_NOTIFICATIONS -- (void)windowDragStart:(NSNotification *)notification { + +- (void) windowDragStart: (NSNotification *) notification +{ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); } -- (void)windowLiveResize:(NSNotification *)notification { + +- (void) windowLiveResize: (NSNotification *) notification +{ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); //BOOL start = [[notification name] isEqualToString:NSWindowWillStartLiveResizeNotification]; } -- (void)windowMapped:(NSNotification *)notification { + +- (void) windowMapped: (NSNotification *) notification +{ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); @@ -163,12 +190,14 @@ extern NSString *NSWindowDidOrderOffScreenNotification; //Tk_MapWindow((Tk_Window) winPtr); } } -- (void)windowBecameVisible:(NSNotification *)notification { -#ifdef TK_MAC_DEBUG_NOTIFICATIONS + +- (void) windowBecameVisible: (NSNotification *) notification +{ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); -#endif } -- (void)windowUnmapped:(NSNotification *)notification { + +- (void) windowUnmapped: (NSNotification *) notification +{ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); @@ -177,11 +206,14 @@ extern NSString *NSWindowDidOrderOffScreenNotification; //Tk_UnmapWindow((Tk_Window) winPtr); } } -#endif +#endif /* TK_MAC_DEBUG_NOTIFICATIONS */ -- (void)_setupWindowNotifications { +- (void) _setupWindowNotifications +{ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; -#define observe(n, s) [nc addObserver:self selector:@selector(s) name:(n) object:nil] + +#define observe(n, s) \ + [nc addObserver:self selector:@selector(s) name:(n) object:nil] observe(NSWindowDidBecomeKeyNotification, windowActivation:); observe(NSWindowDidResignKeyNotification, windowActivation:); observe(NSWindowDidMoveNotification, windowBoundsChanged:); @@ -200,23 +232,29 @@ extern NSString *NSWindowDidOrderOffScreenNotification; #undef observe } @end - + #pragma mark TKApplication(TKApplicationEvent) @implementation TKApplication(TKApplicationEvent) -- (void)applicationActivate:(NSNotification *)notification { + +- (void) applicationActivate: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif [NSApp tkCheckPasteboard]; } -- (void)applicationDeactivate:(NSNotification *)notification { + +- (void) applicationDeactivate: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif TkSuspendClipboard(); } -- (void)applicationShowHide:(NSNotification *)notification { + +- (void) applicationShowHide: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif @@ -227,13 +265,16 @@ extern NSString *NSWindowDidOrderOffScreenNotification; if (_eventInterp && Tcl_GetCommandInfo(_eventInterp, cmd, &dummy)) { int code = Tcl_EvalEx(_eventInterp, cmd, -1, TCL_EVAL_GLOBAL); + if (code != TCL_OK) { Tcl_BackgroundException(_eventInterp, code); } Tcl_ResetResult(_eventInterp); } } -- (void)displayChanged:(NSNotification *)notification { + +- (void) displayChanged: (NSNotification *) notification +{ #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif @@ -355,8 +396,8 @@ GenerateUpdates( * * GenerateActivateEvents -- * - * Given a Macintosh window activate event this function generates all - * the X Activate events needed by Tk. + * Given a Macintosh window activate event this function generates all the + * X Activate events needed by Tk. * * Results: * True if event(s) are generated - false otherwise. @@ -462,8 +503,8 @@ TkMacOSXGenerateFocusEvent( * * TkGenWMConfigureEvent -- * - * Generate a ConfigureNotify event for Tk. Depending on the value of - * flag the values of width/height, x/y, or both may be changed. + * Generate a ConfigureNotify event for Tk. Depending on the value of flag + * the values of width/height, x/y, or both may be changed. * * Results: * None. @@ -477,10 +518,8 @@ TkMacOSXGenerateFocusEvent( void TkGenWMConfigureEvent( Tk_Window tkwin, - int x, - int y, - int width, - int height, + int x, int y, + int width, int height, int flags) { XEvent event; @@ -542,33 +581,31 @@ TkGenWMConfigureEvent( * Don't set external width, since the user didn't change it * from what the widgets asked for. */ - } else { - if (wmPtr->gridWin != NULL) { - wmPtr->width = wmPtr->reqGridWidth - + (width - winPtr->reqWidth)/wmPtr->widthInc; - if (wmPtr->width < 0) { - wmPtr->width = 0; - } - } else { - wmPtr->width = width; + } else if (wmPtr->gridWin != NULL) { + wmPtr->width = wmPtr->reqGridWidth + + (width - winPtr->reqWidth)/wmPtr->widthInc; + if (wmPtr->width < 0) { + wmPtr->width = 0; } + } else { + wmPtr->width = width; } + if ((wmPtr->height == -1) && (height == winPtr->reqHeight)) { /* * Don't set external height, since the user didn't change it * from what the widgets asked for. */ - } else { - if (wmPtr->gridWin != NULL) { - wmPtr->height = wmPtr->reqGridHeight - + (height - winPtr->reqHeight)/wmPtr->heightInc; - if (wmPtr->height < 0) { - wmPtr->height = 0; - } - } else { - wmPtr->height = height; + } else if (wmPtr->gridWin != NULL) { + wmPtr->height = wmPtr->reqGridHeight + + (height - winPtr->reqHeight)/wmPtr->heightInc; + if (wmPtr->height < 0) { + wmPtr->height = 0; } + } else { + wmPtr->height = height; } + wmPtr->configWidth = width; wmPtr->configHeight = height; } @@ -628,10 +665,9 @@ TkGenWMDestroyEvent( * * TkWmProtocolEventProc -- * - * This procedure is called by the Tk_HandleEvent whenever a - * ClientMessage event arrives whose type is "WM_PROTOCOLS". This - * procedure handles the message from the window manager in an - * appropriate fashion. + * This procedure is called by the Tk_HandleEvent whenever a ClientMessage + * event arrives whose type is "WM_PROTOCOLS". This procedure handles the + * message from the window manager in an appropriate fashion. * * Results: * None. @@ -718,7 +754,7 @@ Tk_MacOSXIsAppInFront(void) return (isFrontProcess == true); } - + #pragma mark TKContentView #import <ApplicationServices/ApplicationServices.h> @@ -728,34 +764,39 @@ Tk_MacOSXIsAppInFront(void) * The goal is to emulate X11-style drawing in response to Expose events: * during the normal AppKit drawing cycle, we supress drawing of all subviews * (using a technique adapted from WebKit's WebHTMLView) and instead send - * Expose events about the subviews that would be redrawn. - * Tk Expose event handling and drawing handlers then draw the subviews - * manually via their -displayRectIgnoringOpacity: + * Expose events about the subviews that would be redrawn. Tk Expose event + * handling and drawing handlers then draw the subviews manually via their + * -displayRectIgnoringOpacity: */ @interface TKContentView(TKWindowEvent) -- (void)drawRect:(NSRect)rect; -- (void)generateExposeEvents:(HIMutableShapeRef)shape; -- (BOOL)isOpaque; -- (BOOL)wantsDefaultClipping; -- (BOOL)acceptsFirstResponder; -- (void)keyDown:(NSEvent *)theEvent; +- (void) drawRect: (NSRect) rect; +- (void) generateExposeEvents: (HIMutableShapeRef) shape; +- (BOOL) isOpaque; +- (BOOL) wantsDefaultClipping; +- (BOOL) acceptsFirstResponder; +- (void) keyDown: (NSEvent *) theEvent; @end @implementation TKContentView @end -static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) +static Tk_RestrictAction +ExposeRestrictProc( + ClientData arg, + XEvent *eventPtr) { - return (eventPtr->type == Expose && eventPtr->xany.serial == PTR2UINT(arg) ? - TK_PROCESS_EVENT : TK_DEFER_EVENT); + return (eventPtr->type==Expose && eventPtr->xany.serial==PTR2UINT(arg) + ? TK_PROCESS_EVENT : TK_DEFER_EVENT); } @implementation TKContentView(TKWindowEvent) -- (void)drawRect:(NSRect)rect { +- (void) drawRect: (NSRect) rect +{ const NSRect *rectsBeingDrawn; NSInteger rectsBeingDrawnCount; + [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount]; #ifdef TK_MAC_DEBUG_DRAWING TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromRect(rect)); @@ -763,17 +804,23 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) NSRectFillListUsingOperation(rectsBeingDrawn, rectsBeingDrawnCount, NSCompositeSourceOver); #endif + NSWindow *w = [self window]; + if ([self isOpaque] && [w showsResizeIndicator]) { NSRect bounds = [self convertRect:[w _growBoxRect] fromView:nil]; + if ([self needsToDrawRect:bounds]) { NSEraseRect(bounds); } } + CGFloat height = [self bounds].size.height; HIMutableShapeRef drawShape = HIShapeCreateMutable(); + while (rectsBeingDrawnCount--) { CGRect r = NSRectToCGRect(*rectsBeingDrawn++); + r.origin.y = height - (r.origin.y + r.size.height); HIShapeUnionWithRect(drawShape, &r); } @@ -789,7 +836,8 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) CFRelease(drawShape); } -- (void)generateExposeEvents:(HIMutableShapeRef)shape { +- (void) generateExposeEvents: (HIMutableShapeRef) shape +{ TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); unsigned long serial; CGRect updateBounds; @@ -803,8 +851,8 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) ![[NSRunLoop currentRunLoop] currentMode] && Tcl_GetServiceMode() != TCL_SERVICE_NONE) { /* - * Ensure there are no pending idle-time redraws that could prevent - * the just posted Expose events from generating new redraws. + * Ensure there are no pending idle-time redraws that could prevent the + * just posted Expose events from generating new redraws. */ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} @@ -817,13 +865,15 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) ClientData oldArg; Tk_RestrictProc *oldProc = Tk_RestrictEvents(ExposeRestrictProc, UINT2PTR(serial), &oldArg); + while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {} Tk_RestrictEvents(oldProc, oldArg, &oldArg); while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} } } -- (void)tkToolbarButton:(id)sender { +- (void) tkToolbarButton: (id) sender +{ #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd); #endif @@ -850,39 +900,48 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) } #ifdef TK_MAC_DEBUG_DRAWING -- (void)setFrameSize:(NSSize)newSize { - TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromSize(newSize)); +- (void) setFrameSize: (NSSize) newSize +{ + TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, + NSStringFromSize(newSize)); [super setFrameSize:newSize]; } -- (void)setNeedsDisplayInRect:(NSRect)invalidRect { + +- (void) setNeedsDisplayInRect: (NSRect) invalidRect +{ TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromRect(invalidRect)); [super setNeedsDisplayInRect:invalidRect]; } #endif -- (BOOL)isOpaque { + +- (BOOL) isOpaque +{ NSWindow *w = [self window]; return (w && (([w styleMask] & NSTexturedBackgroundWindowMask) || ![w isOpaque]) ? NO : YES); } -- (BOOL)wantsDefaultClipping { +- (BOOL) wantsDefaultClipping +{ return NO; } -- (BOOL)acceptsFirstResponder { +- (BOOL) acceptsFirstResponder +{ return YES; } -- (void)keyDown:(NSEvent *)theEvent { +- (void) keyDown: (NSEvent *) theEvent +{ #ifdef TK_MAC_DEBUG_EVENTS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif } @end - + #pragma mark TKContentViewPrivate /* @@ -892,25 +951,31 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) */ @interface TKContentView(TKContentViewPrivate) -- (id)initWithFrame:(NSRect)frame; -- (void)_setAsideSubviews; -- (void)_restoreSubviews; +- (id) initWithFrame: (NSRect) frame; +- (void) _setAsideSubviews; +- (void) _restoreSubviews; @end @interface NSView(TKContentViewPrivate) -- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)rect isVisibleRect:(BOOL)isVisibleRect rectIsVisibleRectForView:(NSView *)visibleView topView:(BOOL)topView; -- (void)_recursiveDisplayAllDirtyWithLockFocus:(BOOL)needsLockFocus visRect:(NSRect)visRect; -- (void)_recursive:(BOOL)recurse displayRectIgnoringOpacity:(NSRect)displayRect inContext:(NSGraphicsContext *)context topView:(BOOL)topView; -- (void)_lightWeightRecursiveDisplayInRect:(NSRect)visRect; -- (BOOL)_drawRectIfEmpty; -- (void)_drawRect:(NSRect)inRect clip:(BOOL)clip; -- (void)_setDrawsOwnDescendants:(BOOL)drawsOwnDescendants; +- (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect + isVisibleRect: (BOOL) isVisibleRect + rectIsVisibleRectForView: (NSView *) visibleView + topView: (BOOL) topView; +- (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus + visRect: (NSRect) visRect; +- (void) _recursive: (BOOL) recurse + displayRectIgnoringOpacity: (NSRect) displayRect + inContext: (NSGraphicsContext *) context topView: (BOOL) topView; +- (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect; +- (BOOL) _drawRectIfEmpty; +- (void) _drawRect: (NSRect) inRect clip: (BOOL) clip; +- (void) _setDrawsOwnDescendants: (BOOL) drawsOwnDescendants; @end - @implementation TKContentView(TKContentViewPrivate) -- (id)initWithFrame:(NSRect)frame { +- (id) initWithFrame: (NSRect) frame +{ self = [super initWithFrame:frame]; if (self) { _savedSubviews = nil; @@ -920,7 +985,7 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) return self; } -- (void)_setAsideSubviews +- (void) _setAsideSubviews { #ifdef TK_MAC_DEBUG if (_subviewsSetAside || _savedSubviews) { @@ -930,10 +995,10 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) _savedSubviews = _subviews; _subviews = nil; _subviewsSetAside = YES; - } +} - - (void)_restoreSubviews - { +- (void) _restoreSubviews +{ #ifdef TK_MAC_DEBUG if (!_subviewsSetAside || _subviews) { Tcl_Panic("TKContentView _restoreSubviews called incorrectly"); @@ -944,34 +1009,48 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) _subviewsSetAside = NO; } -- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)rect isVisibleRect:(BOOL)isVisibleRect rectIsVisibleRectForView:(NSView *)visibleView topView:(BOOL)topView +- (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect + isVisibleRect: (BOOL) isVisibleRect + rectIsVisibleRectForView: (NSView *) visibleView + topView: (BOOL) topView { [self _setAsideSubviews]; - [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView topView:topView]; + [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect + isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView + topView:topView]; [self _restoreSubviews]; } -- (void)_recursiveDisplayAllDirtyWithLockFocus:(BOOL)needsLockFocus visRect:(NSRect)visRect +- (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus + visRect: (NSRect) visRect { BOOL needToSetAsideSubviews = !_subviewsSetAside; + if (needToSetAsideSubviews) { [self _setAsideSubviews]; } - [super _recursiveDisplayAllDirtyWithLockFocus:needsLockFocus visRect:visRect]; + [super _recursiveDisplayAllDirtyWithLockFocus:needsLockFocus + visRect:visRect]; if (needToSetAsideSubviews) { [self _restoreSubviews]; } } -- (void)_recursive:(BOOL)recurse displayRectIgnoringOpacity:(NSRect)displayRect inContext:(NSGraphicsContext *)context topView:(BOOL)topView +- (void) _recursive: (BOOL) recurse + displayRectIgnoringOpacity: (NSRect) displayRect + inContext: (NSGraphicsContext *) context topView: (BOOL) topView { [self _setAsideSubviews]; - [super _recursive:recurse displayRectIgnoringOpacity:displayRect inContext:context topView:topView]; + [super _recursive:recurse + displayRectIgnoringOpacity:displayRect inContext:context + topView:topView]; [self _restoreSubviews]; } -- (void)_lightWeightRecursiveDisplayInRect:(NSRect)visRect { +- (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect +{ BOOL needToSetAsideSubviews = !_subviewsSetAside; + if (needToSetAsideSubviews) { [self _setAsideSubviews]; } @@ -981,19 +1060,24 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) } } -- (BOOL)_drawRectIfEmpty { +- (BOOL) _drawRectIfEmpty +{ /* * Our -drawRect manages subview drawing directly, so it needs to be called * even if the area to be redrawn is completely obscured by subviews. */ + return YES; } -- (void)_drawRect:(NSRect)inRect clip:(BOOL)clip { +- (void) _drawRect: (NSRect) inRect clip: (BOOL) clip +{ #ifdef TK_MAC_DEBUG_DRAWING - TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromRect(inRect)); + TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, + NSStringFromRect(inRect)); #endif BOOL subviewsWereSetAside = _subviewsSetAside; + if (subviewsWereSetAside) { [self _restoreSubviews]; } @@ -1007,7 +1091,7 @@ static Tk_RestrictAction ExposeRestrictProc(ClientData arg, XEvent *eventPtr) /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index bdb7bf9..17d4320 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXWm.c,v 1.75 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.76 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -321,7 +321,7 @@ static void RemapWindows(TkWindow *winPtr, #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 @interface NSWindow(TkWm) -- (void)setCanCycle:(BOOL)canCycleFlag; +- (void) setCanCycle: (BOOL) canCycleFlag; @end #endif @@ -335,7 +335,8 @@ static void RemapWindows(TkWindow *winPtr, @end @implementation TKWindow(TKWm) -- (BOOL)canBecomeKeyWindow { +- (BOOL) canBecomeKeyWindow +{ TkWindow *winPtr = TkMacOSXGetTkWindow(self); return (winPtr && winPtr->wmInfoPtr && (winPtr->wmInfoPtr->macClass == @@ -6491,7 +6492,7 @@ RemapWindows( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index f3b3cc1..8bef50d 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.32 2009/06/29 14:35:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.33 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -1335,7 +1335,7 @@ Tk_ResetUserInactiveTime( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 |