Various minor fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3929 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-03-16 16:38:26 +00:00
parent aa8df77c85
commit d62468c82b
6 changed files with 64 additions and 81 deletions

View file

@ -1,3 +1,14 @@
Mon Mar 15 16:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* 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 <richard@brainstorm.co.uk>
* Source/NSView.m: ([-resizeWithOldSuperviewSize:]) Added fix so this

View file

@ -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];

View file

@ -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];

View file

@ -96,7 +96,7 @@ static NSMutableDictionary *colorStrings = nil;
gray, @"gridColor",
white, @"highlightColor",
lightGray, @"knobColor",
lightGray, @"scrollBarColor",
gray, @"scrollBarColor",
white, @"selectedControlColor",
black, @"selectedControlTextColor",
white, @"selectedMenuItemColor",

View file

@ -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

View file

@ -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: