mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:10:48 +00:00
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:
parent
7173823879
commit
2d554ab9d7
6 changed files with 64 additions and 81 deletions
11
ChangeLog
11
ChangeLog
|
@ -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>
|
Mon Mar 15 10:15:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/NSView.m: ([-resizeWithOldSuperviewSize:]) Added fix so this
|
* Source/NSView.m: ([-resizeWithOldSuperviewSize:]) Added fix so this
|
||||||
|
|
|
@ -484,8 +484,13 @@ NSString* mainModelFile;
|
||||||
/*
|
/*
|
||||||
* Check to see if the window has gone away - if so, end session.
|
* Check to see if the window has gone away - if so, end session.
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
if ([[self windows] indexOfObjectIdenticalTo: session->window] ==
|
if ([[self windows] indexOfObjectIdenticalTo: session->window] ==
|
||||||
NSNotFound || [session->window isVisible] == NO)
|
NSNotFound || [session->window isVisible] == NO)
|
||||||
|
#else
|
||||||
|
if ([[self windows] indexOfObjectIdenticalTo: session->window] ==
|
||||||
|
NSNotFound)
|
||||||
|
#endif
|
||||||
[self stopModal];
|
[self stopModal];
|
||||||
if (windows_need_update)
|
if (windows_need_update)
|
||||||
[self updateWindows];
|
[self updateWindows];
|
||||||
|
|
|
@ -132,8 +132,10 @@
|
||||||
NSPoint destPoint = intersection.origin;
|
NSPoint destPoint = intersection.origin;
|
||||||
float dx = newBounds.origin.x - originalBounds.origin.x;
|
float dx = newBounds.origin.x - originalBounds.origin.x;
|
||||||
float dy = newBounds.origin.y - originalBounds.origin.y;
|
float dy = newBounds.origin.y - originalBounds.origin.y;
|
||||||
|
|
||||||
destPoint.x -= dx;
|
destPoint.x -= dx;
|
||||||
destPoint.y -= dy;
|
destPoint.y -= dy;
|
||||||
|
[window update]; // Make sure display is up to date.
|
||||||
[self lockFocus];
|
[self lockFocus];
|
||||||
NSCopyBits(0, intersection, destPoint);
|
NSCopyBits(0, intersection, destPoint);
|
||||||
[self unlockFocus];
|
[self unlockFocus];
|
||||||
|
|
|
@ -96,7 +96,7 @@ static NSMutableDictionary *colorStrings = nil;
|
||||||
gray, @"gridColor",
|
gray, @"gridColor",
|
||||||
white, @"highlightColor",
|
white, @"highlightColor",
|
||||||
lightGray, @"knobColor",
|
lightGray, @"knobColor",
|
||||||
lightGray, @"scrollBarColor",
|
gray, @"scrollBarColor",
|
||||||
white, @"selectedControlColor",
|
white, @"selectedControlColor",
|
||||||
black, @"selectedControlTextColor",
|
black, @"selectedControlTextColor",
|
||||||
white, @"selectedMenuItemColor",
|
white, @"selectedMenuItemColor",
|
||||||
|
|
|
@ -45,26 +45,6 @@
|
||||||
|
|
||||||
static NSMutableArray* imageReps = NULL;
|
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
|
@implementation NSImageRep
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
|
@ -96,11 +76,14 @@ extension(NSString *name)
|
||||||
NSString* ext;
|
NSString* ext;
|
||||||
NSMutableArray* array;
|
NSMutableArray* array;
|
||||||
|
|
||||||
ext = extension(filename);
|
ext = [filename pathExtension];
|
||||||
// FIXME: Should this be an exception? Should we even check this?
|
// FIXME: Should this be an exception? Should we even check this?
|
||||||
if (!ext)
|
if (!ext)
|
||||||
return nil;
|
{
|
||||||
array = [NSMutableArray arrayWithCapacity:1];
|
NSLog(@"extension missing from filename - '%@'", filename);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
array = [NSMutableArray arrayWithCapacity: 1];
|
||||||
|
|
||||||
count = [imageReps count];
|
count = [imageReps count];
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
|
@ -115,14 +98,10 @@ extension(NSString *name)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
NSData* data = [NSData dataWithContentsOfFile: filename];
|
NSData* data = [NSData dataWithContentsOfFile: filename];
|
||||||
#if 1
|
|
||||||
if ([rep respondsToSelector: @selector(imageRepsWithData:)])
|
if ([rep respondsToSelector: @selector(imageRepsWithData:)])
|
||||||
#endif
|
|
||||||
[array addObjectsFromArray: [rep imageRepsWithData: data]];
|
[array addObjectsFromArray: [rep imageRepsWithData: data]];
|
||||||
#if 1
|
|
||||||
else if ([rep respondsToSelector: @selector(imageRepWithData:)])
|
else if ([rep respondsToSelector: @selector(imageRepWithData:)])
|
||||||
[array addObject: [rep imageRepWithData: data]];
|
[array addObject: [rep imageRepWithData: data]];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (NSArray *)array;
|
return (NSArray *)array;
|
||||||
|
@ -143,7 +122,7 @@ extension(NSString *name)
|
||||||
int i, count;
|
int i, count;
|
||||||
NSMutableArray* array;
|
NSMutableArray* array;
|
||||||
|
|
||||||
array = [NSMutableArray arrayWithCapacity:1];
|
array = [NSMutableArray arrayWithCapacity: 1];
|
||||||
|
|
||||||
count = [imageReps count];
|
count = [imageReps count];
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
|
@ -152,7 +131,7 @@ extension(NSString *name)
|
||||||
Class rep = [imageReps objectAtIndex: i];
|
Class rep = [imageReps objectAtIndex: i];
|
||||||
if ([rep respondsToSelector: @selector(imagePasteboardTypes)]
|
if ([rep respondsToSelector: @selector(imagePasteboardTypes)]
|
||||||
&& (ptype =
|
&& (ptype =
|
||||||
[pasteboard availableTypeFromArray:[rep imagePasteboardTypes]]))
|
[pasteboard availableTypeFromArray: [rep imagePasteboardTypes]]))
|
||||||
{
|
{
|
||||||
NSData* data = [pasteboard dataForType: ptype];
|
NSData* data = [pasteboard dataForType: ptype];
|
||||||
if ([rep respondsToSelector: @selector(imageRepsWithData:)])
|
if ([rep respondsToSelector: @selector(imageRepsWithData:)])
|
||||||
|
@ -221,7 +200,7 @@ extension(NSString *name)
|
||||||
// Specifying Information about the Representation
|
// Specifying Information about the Representation
|
||||||
- (int) bitsPerSample
|
- (int) bitsPerSample
|
||||||
{
|
{
|
||||||
return bitsPerSample;
|
return bitsPerSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) colorSpaceName
|
- (NSString *) colorSpaceName
|
||||||
|
@ -349,11 +328,9 @@ extension(NSString *name)
|
||||||
+ (void) registerImageRepClass: (Class)imageRepClass
|
+ (void) registerImageRepClass: (Class)imageRepClass
|
||||||
{
|
{
|
||||||
[imageReps addObject: imageRepClass];
|
[imageReps addObject: imageRepClass];
|
||||||
/*
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName: NSImageRepRegistryChangedNotification
|
postNotificationName: NSImageRepRegistryChangedNotification
|
||||||
object: self];
|
object: self];
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray *) registeredImageRepClasses
|
+ (NSArray *) registeredImageRepClasses
|
||||||
|
@ -366,7 +343,7 @@ extension(NSString *name)
|
||||||
[imageReps removeObject: imageRepClass];
|
[imageReps removeObject: imageRepClass];
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName: NSImageRepRegistryChangedNotification
|
postNotificationName: NSImageRepRegistryChangedNotification
|
||||||
object: self];
|
object: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSCoding protocol
|
// NSCoding protocol
|
||||||
|
|
|
@ -55,9 +55,8 @@ static NSButtonCell* leftCell = nil; // to draw scroller
|
||||||
static NSButtonCell* rightCell = nil; // buttons and knob.
|
static NSButtonCell* rightCell = nil; // buttons and knob.
|
||||||
static NSButtonCell* knobCell = nil;
|
static NSButtonCell* knobCell = nil;
|
||||||
|
|
||||||
static const float scrollerWidth = 17;
|
static const float scrollerWidth = 18;
|
||||||
static const float buttonsWidth = 16;
|
static const float buttonsWidth = 16;
|
||||||
static const float buttonsDistance = 1;
|
|
||||||
|
|
||||||
static float halfKnobRectHeight;
|
static float halfKnobRectHeight;
|
||||||
static float slotOriginPlusKnobHeight;
|
static float slotOriginPlusKnobHeight;
|
||||||
|
@ -258,16 +257,16 @@ static BOOL preCalcValues = NO;
|
||||||
|
|
||||||
if (_arrowsPosition == NSScrollerArrowsNone)
|
if (_arrowsPosition == NSScrollerArrowsNone)
|
||||||
{
|
{
|
||||||
if (size > scrollerWidth + 1)
|
if (size >= scrollerWidth + 2)
|
||||||
_usableParts = NSAllScrollerParts;
|
_usableParts = NSAllScrollerParts;
|
||||||
else
|
else
|
||||||
_usableParts = NSNoScrollerParts;
|
_usableParts = NSNoScrollerParts;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (size > 3 * scrollerWidth + 2)
|
if (size >= 3 * scrollerWidth + 4)
|
||||||
_usableParts = NSAllScrollerParts;
|
_usableParts = NSAllScrollerParts;
|
||||||
else if (size > 2 * scrollerWidth + 1)
|
else if (size >= 2 * scrollerWidth + 3)
|
||||||
_usableParts = NSOnlyScrollerArrows;
|
_usableParts = NSOnlyScrollerArrows;
|
||||||
else
|
else
|
||||||
_usableParts = NSNoScrollerParts;
|
_usableParts = NSNoScrollerParts;
|
||||||
|
@ -353,8 +352,8 @@ static BOOL preCalcValues = NO;
|
||||||
// return what part of the scroller the mouse hit
|
// return what part of the scroller the mouse hit
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
|
|
||||||
if (thePoint.x < 0 || thePoint.x > frame.size.width
|
if (thePoint.x <= 0 || thePoint.x >= frame.size.width
|
||||||
|| thePoint.y < 0 || thePoint.y > frame.size.height)
|
|| thePoint.y <= 0 || thePoint.y >= frame.size.height)
|
||||||
return NSScrollerNoPart;
|
return NSScrollerNoPart;
|
||||||
|
|
||||||
rect = [self rectForPart: NSScrollerDecrementLine];
|
rect = [self rectForPart: NSScrollerDecrementLine];
|
||||||
|
@ -747,7 +746,7 @@ static BOOL preCalcValues = NO;
|
||||||
else
|
else
|
||||||
rect = [self rectForPart: NSScrollerKnobSlot];
|
rect = [self rectForPart: NSScrollerKnobSlot];
|
||||||
|
|
||||||
[[NSColor darkGrayColor] set];
|
[[NSColor scrollBarColor] set];
|
||||||
NSRectFill(rect);
|
NSRectFill(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -773,8 +772,9 @@ static BOOL preCalcValues = NO;
|
||||||
- (NSRect) rectForPart: (NSScrollerPart)partCode
|
- (NSRect) rectForPart: (NSScrollerPart)partCode
|
||||||
{
|
{
|
||||||
NSRect scrollerFrame = frame;
|
NSRect scrollerFrame = frame;
|
||||||
float x = 0, y = 0;
|
float x = 1, y = 1;
|
||||||
float width, height;
|
float width, height;
|
||||||
|
float buttonsSize = 2 * buttonsWidth + 2;
|
||||||
NSUsableScrollerParts usableParts;
|
NSUsableScrollerParts usableParts;
|
||||||
// If the scroller is disabled then the scroller buttons and the
|
// If the scroller is disabled then the scroller buttons and the
|
||||||
// knob are not displayed at all.
|
// knob are not displayed at all.
|
||||||
|
@ -789,13 +789,13 @@ static BOOL preCalcValues = NO;
|
||||||
// but keeps track of the scroller's orientation.
|
// but keeps track of the scroller's orientation.
|
||||||
if (_isHorizontal)
|
if (_isHorizontal)
|
||||||
{
|
{
|
||||||
width = scrollerFrame.size.height;
|
width = scrollerFrame.size.height - 2;
|
||||||
height = scrollerFrame.size.width;
|
height = scrollerFrame.size.width - 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
width = scrollerFrame.size.width;
|
width = scrollerFrame.size.width - 2;
|
||||||
height = scrollerFrame.size.height;
|
height = scrollerFrame.size.height - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The x, y, width and height values are computed below for the vertical
|
// The x, y, width and height values are computed below for the vertical
|
||||||
|
@ -812,7 +812,7 @@ static BOOL preCalcValues = NO;
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
// calc the slot Height
|
// calc the slot Height
|
||||||
slotHeight = height - (_arrowsPosition == NSScrollerArrowsNone ?
|
slotHeight = height - (_arrowsPosition == NSScrollerArrowsNone ?
|
||||||
0 : 2 * (buttonsWidth + buttonsDistance));
|
0 : buttonsSize);
|
||||||
knobHeight = _knobProportion * slotHeight;
|
knobHeight = _knobProportion * slotHeight;
|
||||||
if (knobHeight < buttonsWidth)
|
if (knobHeight < buttonsWidth)
|
||||||
knobHeight = buttonsWidth;
|
knobHeight = buttonsWidth;
|
||||||
|
@ -820,74 +820,62 @@ static BOOL preCalcValues = NO;
|
||||||
knobPosition = _floatValue * (slotHeight - knobHeight);
|
knobPosition = _floatValue * (slotHeight - knobHeight);
|
||||||
knobPosition = (float)floor(knobPosition); // avoid rounding error
|
knobPosition = (float)floor(knobPosition); // avoid rounding error
|
||||||
// calc actual position
|
// calc actual position
|
||||||
y = knobPosition + (_arrowsPosition == NSScrollerArrowsMaxEnd
|
y += knobPosition + (_arrowsPosition == NSScrollerArrowsMaxEnd
|
||||||
|| _arrowsPosition == NSScrollerArrowsNone ?
|
|| _arrowsPosition == NSScrollerArrowsNone ?
|
||||||
0 : 2 * (buttonsWidth + buttonsDistance));
|
0 : buttonsSize);
|
||||||
height = knobHeight;
|
height = knobHeight;
|
||||||
width = buttonsWidth;
|
width = buttonsWidth;
|
||||||
#if 0
|
|
||||||
if (_isHorizontal) // keeps horiz knob off of the buttons
|
|
||||||
y++;
|
|
||||||
#endif
|
|
||||||
x = buttonsDistance;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case NSScrollerKnobSlot:
|
case NSScrollerKnobSlot:
|
||||||
// if the scroller does not have buttons the slot completely
|
// if the scroller does not have buttons the slot completely
|
||||||
// fills the scroller.
|
// fills the scroller.
|
||||||
if (usableParts == NSNoScrollerParts)
|
if (usableParts == NSNoScrollerParts
|
||||||
|
|| _arrowsPosition == NSScrollerArrowsNone)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
height -= buttonsSize;
|
||||||
|
if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
||||||
{
|
{
|
||||||
height -= 2 * (buttonsWidth + buttonsDistance);
|
y += buttonsSize;
|
||||||
}
|
|
||||||
else if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
|
||||||
{
|
|
||||||
y = 2 * (buttonsWidth + buttonsDistance);
|
|
||||||
height -= y;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSScrollerDecrementLine:
|
case NSScrollerDecrementLine:
|
||||||
case NSScrollerDecrementPage:
|
case NSScrollerDecrementPage:
|
||||||
// if scroller has no parts or knob then return a zero rect
|
// if scroller has no parts or knob then return a zero rect
|
||||||
if (usableParts == NSNoScrollerParts)
|
if (usableParts == NSNoScrollerParts
|
||||||
return NSZeroRect;
|
|| _arrowsPosition == NSScrollerArrowsNone)
|
||||||
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
|
||||||
{
|
{
|
||||||
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;
|
width = buttonsWidth;
|
||||||
height = buttonsWidth;
|
height = buttonsWidth;
|
||||||
x = buttonsDistance;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSScrollerIncrementLine:
|
case NSScrollerIncrementLine:
|
||||||
case NSScrollerIncrementPage:
|
case NSScrollerIncrementPage:
|
||||||
if (usableParts == NSNoScrollerParts)
|
if (usableParts == NSNoScrollerParts
|
||||||
return NSZeroRect;
|
|| _arrowsPosition == NSScrollerArrowsNone)
|
||||||
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
|
||||||
{
|
{
|
||||||
y = height - (buttonsWidth + buttonsDistance);
|
return NSZeroRect;
|
||||||
|
}
|
||||||
|
else if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
||||||
|
{
|
||||||
|
y += (height - buttonsWidth);
|
||||||
}
|
}
|
||||||
else if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
else if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
||||||
{
|
{
|
||||||
y = buttonsWidth + buttonsDistance;
|
y += (buttonsWidth + 1);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return NSZeroRect;
|
|
||||||
height = buttonsWidth;
|
height = buttonsWidth;
|
||||||
width = buttonsWidth;
|
width = buttonsWidth;
|
||||||
x = buttonsDistance;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSScrollerNoPart:
|
case NSScrollerNoPart:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue