Coordinate system fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3691 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-02-11 14:56:30 +00:00
parent d181ea9940
commit dc1695e8f8
5 changed files with 43 additions and 63 deletions

View file

@ -1,3 +1,11 @@
Thu Feb 11 14:10:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
Coordinate fixes by Benhur to -
* Source/NSClipView.m: Coordinate fixes by Benhur
* Source/NSColor.m: Retain things properly when decoding.
* Source/NSMatrix.m: Matrix coordinate system is flipped.
* Source/NSScroller.m: Coordinate fixes
Wed Feb 10 12:35:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSClipView.m: Tidy flip-view errors by Benhur

View file

@ -39,7 +39,7 @@
[super init];
[self setAutoresizesSubviews:YES];
[self setBackgroundColor:[NSColor lightGrayColor]];
_copiesOnScroll = NO;
_copiesOnScroll = YES;
return self;
}
@ -86,19 +86,17 @@
}
- (void) scrollToPoint: (NSPoint)point
{
[self setBoundsOrigin: [self constrainScrollPoint: point]];
}
- (void) setBoundsOrigin: (NSPoint)point
{
NSRect originalBounds = [self bounds];
NSRect newBounds = originalBounds;
NSRect intersection;
#ifdef DEBUGLOG
NSPoint currentPoint = [self bounds].origin;
NSLog (@"scrollToPoint: current point (%f, %f), point (%f, %f)",
currentPoint.x, currentPoint.y,
point.x, point.y);
#endif
newBounds.origin = [self constrainScrollPoint: point];
newBounds.origin = point;
if (NSEqualPoints(originalBounds.origin, newBounds.origin))
return;
@ -112,7 +110,7 @@
if (NSEqualRects(intersection, NSZeroRect))
{
// no intersection -- docview should draw everything
[self setBoundsOrigin: newBounds.origin];
[super setBoundsOrigin: newBounds.origin];
[_documentView setNeedsDisplayInRect:
[self convertRect: newBounds toView: _documentView]];
}
@ -127,7 +125,7 @@
NSCopyBits(0, intersection, destPoint);
[self unlockFocus];
[self setBoundsOrigin: newBounds.origin];
[super setBoundsOrigin: newBounds.origin];
if (dx != 0)
{
// moved in x -- redraw a full-height rectangle at
@ -182,10 +180,11 @@
else
{
// dont copy anything -- docview draws it all
[self setBoundsOrigin: newBounds.origin];
[super setBoundsOrigin: newBounds.origin];
[_documentView setNeedsDisplayInRect:
[self convertRect: newBounds toView: _documentView]];
}
[super_view reflectScrolledClipView:self];
}
- (NSPoint) constrainScrollPoint: (NSPoint)proposedNewOrigin
@ -209,6 +208,13 @@
>= documentFrame.size.height - bounds.size.height)
new.y = documentFrame.size.height - bounds.size.height;
// make it an integer coordinate in device space
// to avoid some nice effects when scrolling
new = [self convertPoint:new toView:nil];
new.x = (int)new.x;
new.y = (int)new.y;
new = [self convertPoint:new fromView:nil];
return new;
}
@ -267,12 +273,6 @@
[super_view reflectScrolledClipView:self];
}
- (void) setBoundsOrigin: (NSPoint)aPoint
{
[super setBoundsOrigin:aPoint];
[super_view reflectScrolledClipView:self];
}
- (void) setBoundsSize: (NSSize)aSize
{
[super setBoundsSize:aSize];

View file

@ -1105,9 +1105,9 @@ static NSMutableDictionary *colorStrings = nil;
// +++ Coding cannot return class version yet
// if ([aDecoder versionForClassName: s] > 1)
{
colorspace_name = [aDecoder decodeObject];
catalog_name = [aDecoder decodeObject];
color_name = [aDecoder decodeObject];
colorspace_name = [[aDecoder decodeObject] retain];
catalog_name = [[aDecoder decodeObject] retain];
color_name = [[aDecoder decodeObject] retain];
[aDecoder decodeValueOfObjCType: @encode(float) at: &CMYK_component.cyan];
[aDecoder decodeValueOfObjCType: @encode(float) at: &CMYK_component.magenta];
[aDecoder decodeValueOfObjCType: @encode(float) at: &CMYK_component.yellow];

View file

@ -47,7 +47,7 @@
/* Define the following symbol when NSView will support flipped views */
//#define HAS_FLIPPED_VIEWS 1
#define HAS_FLIPPED_VIEWS 1
#ifdef MIN
# undef MIN
@ -994,30 +994,20 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
int i, j;
int row1, col1; // The cell at the upper left corner
int row2, col2; // The cell at the lower right corner
NSRect intRect, upperLeftRect;
NSArray* row;
if(drawsBackground)
{
[backgroundColor set];
NSRectFill(rect); // draw the background
}
if (drawsBackground)
{
// draw the background
[backgroundColor set];
NSRectFill(rect);
}
[self _getRow:&row1 column:&col1
#if HAS_FLIPPED_VIEWS
forPoint:rect.origin
#else
forPoint:NSMakePoint (rect.origin.x, rect.origin.y + rect.size.height)
#endif
above:NO right:NO
isBetweenCells:NULL];
[self _getRow:&row2 column:&col2
#if HAS_FLIPPED_VIEWS
forPoint:NSMakePoint(rect.origin.x + rect.size.width,
rect.origin.y + rect.size.height)
#else
forPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y)
#endif
forPoint:NSMakePoint(NSMaxX(rect), NSMaxY(rect))
above:NO right:NO
isBetweenCells:NULL];
@ -1029,30 +1019,17 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
//NSLog (@"display cells between (%d, %d) and (%d, %d)",row1,col1, row2, col2);
/* Draw the cells within the drawing rectangle. */
intRect = upperLeftRect = [self cellFrameAtRow:row1 column:col1];
for (i = row1; i <= row2 && i < numRows; i++) {
row = [cells objectAtIndex:i];
intRect.origin.x = upperLeftRect.origin.x;
for (j = col1; j <= col2 && j < numCols; j++) {
NSCell *aCell = [row objectAtIndex:j];
[aCell drawWithFrame:intRect inView:self];
intRect.origin.x += cellSize.width + intercell.width;
}
#if HAS_FLIPPED_VIEWS
intRect.origin.y += cellSize.height + intercell.height;
#else
intRect.origin.y -= cellSize.height + intercell.height;
#endif
}
for (i = row1; i <= row2 && i < numRows; i++)
for (j = col1; j <= col2 && j < numCols; j++)
[self drawCellAtRow:i column:j];
}
- (void)drawCellAtRow:(int)row column:(int)column
{
NSCell *aCell = [self cellAtRow:row column:column];
NSRect cellFrame = [self cellFrameAtRow:row column:column];
NSCell *aCell = [self cellAtRow:row column:column];
NSRect cellFrame = [self cellFrameAtRow:row column:column];
[aCell drawWithFrame:cellFrame inView:self];
[aCell drawWithFrame:cellFrame inView:self];
}
- (void)highlightCell:(BOOL)flag

View file

@ -271,9 +271,6 @@ static BOOL preCalcValues = NO;
- (void) setFloatValue: (float)aFloat
{
if (aFloat == _floatValue)
return;
if (aFloat < 0)
_floatValue = 0;
else if (aFloat > 1)
@ -791,8 +788,6 @@ static BOOL preCalcValues = NO;
// calc the slot Height
slotHeight = height - (arrowsPosition == NSScrollerArrowsNone ?
0 : 2 * (buttonsWidth + buttonsDistance));
if (_isHorizontal)
slotHeight -= 2;
knobHeight = _knobProportion * slotHeight;
if (knobHeight < buttonsWidth)
knobHeight = buttonsWidth;