diff --git a/ChangeLog b/ChangeLog index 1e967ca15..db164cfe3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Mon Mar 15 16:00:00 1999 Richard Frith-Macdonald + + * Source/NSApplication.m: ([-runModalSession:]) fix for windowmaker + doing a windowshade - HACK - need a better solution. + * Source/NSClipView.m: ([-setBoundsOrigin:]) update window before + doing bit copy. + * Source/NSColor.m: Fix default scroller color. + * Source/NSScroller.m: Minor tidyup - use scroller slot color. + * Source/NSImageRep.m: Tidyup - remove workaround for missing NSString + functionality - no longer required. + Mon Mar 15 10:15:00 1999 Richard Frith-Macdonald * Source/NSView.m: ([-resizeWithOldSuperviewSize:]) Added fix so this diff --git a/Source/NSApplication.m b/Source/NSApplication.m index d0f1be07e..8090777e2 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -484,8 +484,13 @@ NSString* mainModelFile; /* * Check to see if the window has gone away - if so, end session. */ +#if 0 if ([[self windows] indexOfObjectIdenticalTo: session->window] == NSNotFound || [session->window isVisible] == NO) +#else + if ([[self windows] indexOfObjectIdenticalTo: session->window] == + NSNotFound) +#endif [self stopModal]; if (windows_need_update) [self updateWindows]; diff --git a/Source/NSClipView.m b/Source/NSClipView.m index 3f4c5a637..ef487f129 100644 --- a/Source/NSClipView.m +++ b/Source/NSClipView.m @@ -132,8 +132,10 @@ NSPoint destPoint = intersection.origin; float dx = newBounds.origin.x - originalBounds.origin.x; float dy = newBounds.origin.y - originalBounds.origin.y; + destPoint.x -= dx; destPoint.y -= dy; + [window update]; // Make sure display is up to date. [self lockFocus]; NSCopyBits(0, intersection, destPoint); [self unlockFocus]; diff --git a/Source/NSColor.m b/Source/NSColor.m index 73b6dab5c..eb75e642b 100644 --- a/Source/NSColor.m +++ b/Source/NSColor.m @@ -96,7 +96,7 @@ static NSMutableDictionary *colorStrings = nil; gray, @"gridColor", white, @"highlightColor", lightGray, @"knobColor", - lightGray, @"scrollBarColor", + gray, @"scrollBarColor", white, @"selectedControlColor", black, @"selectedControlTextColor", white, @"selectedMenuItemColor", diff --git a/Source/NSImageRep.m b/Source/NSImageRep.m index 1424f9a08..e10253929 100644 --- a/Source/NSImageRep.m +++ b/Source/NSImageRep.m @@ -45,26 +45,6 @@ static NSMutableArray* imageReps = NULL; -/* Get the extension from a name */ -static NSString * -extension(NSString *name) -{ -/* Waiting for NSString to be complete */ -#if 0 - return [name pathExtension]; -#else - const char* cname; - char *s; - - cname = [name cString]; - s = strrchr(cname, '.'); - if (s > strrchr(cname, '/')) - return [NSString stringWithCString:s+1]; - else - return nil; -#endif -} - @implementation NSImageRep + (void) initialize @@ -96,11 +76,14 @@ extension(NSString *name) NSString* ext; NSMutableArray* array; - ext = extension(filename); + ext = [filename pathExtension]; // FIXME: Should this be an exception? Should we even check this? if (!ext) - return nil; - array = [NSMutableArray arrayWithCapacity:1]; + { + NSLog(@"extension missing from filename - '%@'", filename); + return nil; + } + array = [NSMutableArray arrayWithCapacity: 1]; count = [imageReps count]; for (i = 0; i < count; i++) @@ -115,14 +98,10 @@ extension(NSString *name) #endif { NSData* data = [NSData dataWithContentsOfFile: filename]; -#if 1 if ([rep respondsToSelector: @selector(imageRepsWithData:)]) -#endif [array addObjectsFromArray: [rep imageRepsWithData: data]]; -#if 1 else if ([rep respondsToSelector: @selector(imageRepWithData:)]) [array addObject: [rep imageRepWithData: data]]; -#endif } } return (NSArray *)array; @@ -143,7 +122,7 @@ extension(NSString *name) int i, count; NSMutableArray* array; - array = [NSMutableArray arrayWithCapacity:1]; + array = [NSMutableArray arrayWithCapacity: 1]; count = [imageReps count]; for (i = 0; i < count; i++) @@ -152,7 +131,7 @@ extension(NSString *name) Class rep = [imageReps objectAtIndex: i]; if ([rep respondsToSelector: @selector(imagePasteboardTypes)] && (ptype = - [pasteboard availableTypeFromArray:[rep imagePasteboardTypes]])) + [pasteboard availableTypeFromArray: [rep imagePasteboardTypes]])) { NSData* data = [pasteboard dataForType: ptype]; if ([rep respondsToSelector: @selector(imageRepsWithData:)]) @@ -221,7 +200,7 @@ extension(NSString *name) // Specifying Information about the Representation - (int) bitsPerSample { - return bitsPerSample; + return bitsPerSample; } - (NSString *) colorSpaceName @@ -349,11 +328,9 @@ extension(NSString *name) + (void) registerImageRepClass: (Class)imageRepClass { [imageReps addObject: imageRepClass]; - /* [[NSNotificationCenter defaultCenter] postNotificationName: NSImageRepRegistryChangedNotification - object: self]; - */ + object: self]; } + (NSArray *) registeredImageRepClasses @@ -366,7 +343,7 @@ extension(NSString *name) [imageReps removeObject: imageRepClass]; [[NSNotificationCenter defaultCenter] postNotificationName: NSImageRepRegistryChangedNotification - object: self]; + object: self]; } // NSCoding protocol diff --git a/Source/NSScroller.m b/Source/NSScroller.m index a9b8525a2..cf80b754d 100644 --- a/Source/NSScroller.m +++ b/Source/NSScroller.m @@ -55,9 +55,8 @@ static NSButtonCell* leftCell = nil; // to draw scroller static NSButtonCell* rightCell = nil; // buttons and knob. static NSButtonCell* knobCell = nil; -static const float scrollerWidth = 17; +static const float scrollerWidth = 18; static const float buttonsWidth = 16; -static const float buttonsDistance = 1; static float halfKnobRectHeight; static float slotOriginPlusKnobHeight; @@ -258,16 +257,16 @@ static BOOL preCalcValues = NO; if (_arrowsPosition == NSScrollerArrowsNone) { - if (size > scrollerWidth + 1) + if (size >= scrollerWidth + 2) _usableParts = NSAllScrollerParts; else _usableParts = NSNoScrollerParts; } else { - if (size > 3 * scrollerWidth + 2) + if (size >= 3 * scrollerWidth + 4) _usableParts = NSAllScrollerParts; - else if (size > 2 * scrollerWidth + 1) + else if (size >= 2 * scrollerWidth + 3) _usableParts = NSOnlyScrollerArrows; else _usableParts = NSNoScrollerParts; @@ -353,8 +352,8 @@ static BOOL preCalcValues = NO; // return what part of the scroller the mouse hit NSRect rect; - if (thePoint.x < 0 || thePoint.x > frame.size.width - || thePoint.y < 0 || thePoint.y > frame.size.height) + if (thePoint.x <= 0 || thePoint.x >= frame.size.width + || thePoint.y <= 0 || thePoint.y >= frame.size.height) return NSScrollerNoPart; rect = [self rectForPart: NSScrollerDecrementLine]; @@ -747,7 +746,7 @@ static BOOL preCalcValues = NO; else rect = [self rectForPart: NSScrollerKnobSlot]; - [[NSColor darkGrayColor] set]; + [[NSColor scrollBarColor] set]; NSRectFill(rect); } @@ -773,8 +772,9 @@ static BOOL preCalcValues = NO; - (NSRect) rectForPart: (NSScrollerPart)partCode { NSRect scrollerFrame = frame; - float x = 0, y = 0; + float x = 1, y = 1; float width, height; + float buttonsSize = 2 * buttonsWidth + 2; NSUsableScrollerParts usableParts; // If the scroller is disabled then the scroller buttons and the // knob are not displayed at all. @@ -789,13 +789,13 @@ static BOOL preCalcValues = NO; // but keeps track of the scroller's orientation. if (_isHorizontal) { - width = scrollerFrame.size.height; - height = scrollerFrame.size.width; + width = scrollerFrame.size.height - 2; + height = scrollerFrame.size.width - 2; } else { - width = scrollerFrame.size.width; - height = scrollerFrame.size.height; + width = scrollerFrame.size.width - 2; + height = scrollerFrame.size.height - 2; } // The x, y, width and height values are computed below for the vertical @@ -812,7 +812,7 @@ static BOOL preCalcValues = NO; return NSZeroRect; // calc the slot Height slotHeight = height - (_arrowsPosition == NSScrollerArrowsNone ? - 0 : 2 * (buttonsWidth + buttonsDistance)); + 0 : buttonsSize); knobHeight = _knobProportion * slotHeight; if (knobHeight < buttonsWidth) knobHeight = buttonsWidth; @@ -820,74 +820,62 @@ static BOOL preCalcValues = NO; knobPosition = _floatValue * (slotHeight - knobHeight); knobPosition = (float)floor(knobPosition); // avoid rounding error // calc actual position - y = knobPosition + (_arrowsPosition == NSScrollerArrowsMaxEnd + y += knobPosition + (_arrowsPosition == NSScrollerArrowsMaxEnd || _arrowsPosition == NSScrollerArrowsNone ? - 0 : 2 * (buttonsWidth + buttonsDistance)); + 0 : buttonsSize); height = knobHeight; width = buttonsWidth; -#if 0 - if (_isHorizontal) // keeps horiz knob off of the buttons - y++; -#endif - x = buttonsDistance; break; } case NSScrollerKnobSlot: // if the scroller does not have buttons the slot completely // fills the scroller. - if (usableParts == NSNoScrollerParts) + if (usableParts == NSNoScrollerParts + || _arrowsPosition == NSScrollerArrowsNone) { break; } - if (_arrowsPosition == NSScrollerArrowsMaxEnd) + height -= buttonsSize; + if (_arrowsPosition == NSScrollerArrowsMinEnd) { - height -= 2 * (buttonsWidth + buttonsDistance); - } - else if (_arrowsPosition == NSScrollerArrowsMinEnd) - { - y = 2 * (buttonsWidth + buttonsDistance); - height -= y; + y += buttonsSize; } break; case NSScrollerDecrementLine: case NSScrollerDecrementPage: // if scroller has no parts or knob then return a zero rect - if (usableParts == NSNoScrollerParts) - return NSZeroRect; - if (_arrowsPosition == NSScrollerArrowsMaxEnd) + if (usableParts == NSNoScrollerParts + || _arrowsPosition == NSScrollerArrowsNone) { - y = height - 2 * (buttonsWidth + buttonsDistance); + return NSZeroRect; } - else if (_arrowsPosition == NSScrollerArrowsMinEnd) + else if (_arrowsPosition == NSScrollerArrowsMaxEnd) { - y = buttonsDistance; + y += (height - buttonsSize + 1); } - else - return NSZeroRect; width = buttonsWidth; height = buttonsWidth; - x = buttonsDistance; break; case NSScrollerIncrementLine: case NSScrollerIncrementPage: - if (usableParts == NSNoScrollerParts) - return NSZeroRect; - if (_arrowsPosition == NSScrollerArrowsMaxEnd) + if (usableParts == NSNoScrollerParts + || _arrowsPosition == NSScrollerArrowsNone) { - y = height - (buttonsWidth + buttonsDistance); + return NSZeroRect; + } + else if (_arrowsPosition == NSScrollerArrowsMaxEnd) + { + y += (height - buttonsWidth); } else if (_arrowsPosition == NSScrollerArrowsMinEnd) { - y = buttonsWidth + buttonsDistance; + y += (buttonsWidth + 1); } - else - return NSZeroRect; height = buttonsWidth; width = buttonsWidth; - x = buttonsDistance; break; case NSScrollerNoPart: