Tidied coordinate stuff to allow for window borders.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6207 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-03-07 12:00:00 +00:00
parent 105f8f8c7d
commit 22b9a6867b
4 changed files with 154 additions and 102 deletions

View file

@ -1,6 +1,15 @@
Tue Mar 07 11:00:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSWindow.m: Changes throughout to use correct offsets for
differences between content rect and frame coordinates.
Base coordinate system is that of the content rect, so conversions
between screen and base coordinates are required except for
borderless windows (where the frame rect is the same as the content
rect).
Tue Mar 07 06:24:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSApplication.m: ([activateignoringOtherApps]) order key
* Source/NSApplication.m: ([activateIgnoringOtherApps]) order key
window to front when activating app.
Tue Mar 7 03:23:55 2000 Nicola Pero <n.pero@mi.flashnet.it>

View file

@ -2256,6 +2256,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
slideBack: (BOOL)slideFlag
{
NSView *dragView = (NSView*)[GSCurrentContext() _dragInfo];
[dragView dragImage: anImage
at: viewLocation
offset: initialOffset

View file

@ -353,22 +353,55 @@ static NSMapTable* windowmaps = NULL;
+ (NSRect) contentRectForFrameRect: (NSRect)aRect
styleMask: (unsigned int)aStyle
{
// FIXME: The server should be asked for the border size
NSGraphicsContext *context = GSCurrentContext();
float t, b, l, r;
DPSstyleoffsets(context, &l, &r, &t, &b, aStyle);
aRect.size.width -= (l + r);
aRect.size.height -= (t + b);
aRect.origin.x += l;
aRect.origin.y += b;
return aRect;
}
+ (NSRect) frameRectForContentRect: (NSRect)aRect
styleMask: (unsigned int)aStyle
{
// FIXME: The server should be asked for the border size
NSGraphicsContext *context = GSCurrentContext();
float t, b, l, r;
DPSstyleoffsets(context, &l, &r, &t, &b, aStyle);
aRect.size.width += (l + r);
aRect.size.height += (t + b);
aRect.origin.x -= l;
aRect.origin.y -= b;
return aRect;
}
+ (NSRect) minFrameWidthWithTitle: (NSString*)aTitle
styleMask: (unsigned int)aStyle
{
// FIXME: The server should be asked for the border size
return NSZeroRect;
NSGraphicsContext *context = GSCurrentContext();
float t, b, l, r;
NSRect f = NSZeroRect;
DPSstyleoffsets(context, &l, &r, &t, &b, aStyle);
f.size.width = l + r;
f.size.height = t + b;
/*
* Assume that the width of the area needed for a button is equal to
* the height of the title bar.
*/
if (aStyle & NSClosableWindowMask)
f.size.width += t;
if (aStyle & NSMiniaturizableWindowMask)
f.size.width += t;
/*
* FIXME - title width has to be better determined than this.
* need to get correct values from font.
*/
f.size.width += [aTitle length] * 10;
return f;
}
/* default Screen and window depth */
@ -488,7 +521,8 @@ static NSMapTable* windowmaps = NULL;
style_mask = aStyle;
frame = [NSWindow frameRectForContentRect: contentRect styleMask: aStyle];
minimum_size = NSMakeSize(1, 1);
minimum_size = NSMakeSize(frame.size.width - contentRect.size.width + 1,
frame.size.height - contentRect.size.height + 1);
maximum_size = r.size;
[self setNextResponder: NSApp];
@ -498,13 +532,13 @@ static NSMapTable* windowmaps = NULL;
/* Create the window view */
cframe.origin = NSZeroPoint;
cframe.size = frame.size;
cframe.size = contentRect.size;
_wv = [[GSWindowView allocWithZone: [self zone]] initWithFrame: cframe];
[_wv viewWillMoveToWindow: self];
/* Create the content view */
cframe.origin = NSZeroPoint;
cframe.size = frame.size;
cframe.size = contentRect.size;
[self setContentView: AUTORELEASE([[NSView alloc] initWithFrame: cframe])];
/* rectBeingDrawn is variable used to optimize flushing the backing store.
@ -1132,8 +1166,10 @@ static NSMapTable* windowmaps = NULL;
- (NSRect) constrainFrameRect: (NSRect)frameRect toScreen: screen
{
// FIXME: The implementation of this method is missing
return NSZeroRect;
NSRect r = [screen frame];
r = NSIntersectionRect(r, frameRect);
return r;
}
- (NSRect) frame
@ -1156,6 +1192,8 @@ static NSMapTable* windowmaps = NULL;
NSRect r = frame;
r.size = aSize;
r = [NSWindow frameRectForContentRect: r styleMask: style_mask];
r.origin = frame.origin;
[self setFrame: r display: YES];
}
@ -1271,20 +1309,26 @@ static NSMapTable* windowmaps = NULL;
*/
- (NSPoint) convertBaseToScreen: (NSPoint)basePoint
{
NSGraphicsContext *context = GSCurrentContext();
NSPoint screenPoint;
float t, b, l, r;
screenPoint.x = frame.origin.x + basePoint.x;
screenPoint.y = frame.origin.y + basePoint.y;
DPSstyleoffsets(context, &l, &r, &t, &b, style_mask);
screenPoint.x = frame.origin.x + basePoint.x + l;
screenPoint.y = frame.origin.y + basePoint.y + b;
return screenPoint;
}
- (NSPoint) convertScreenToBase: (NSPoint)screenPoint
{
NSGraphicsContext *context = GSCurrentContext();
NSPoint basePoint;
float t, b, l, r;
basePoint.x = screenPoint.x - frame.origin.x;
basePoint.y = screenPoint.y - frame.origin.y;
DPSstyleoffsets(context, &l, &r, &t, &b, style_mask);
basePoint.x = screenPoint.x - frame.origin.x - l;
basePoint.y = screenPoint.y - frame.origin.y - b;
return basePoint;
}
@ -1914,13 +1958,11 @@ resetCursorRectsForView(NSView *theView)
* loop status */
- (NSPoint) mouseLocationOutsideOfEventStream
{
float x;
float y;
NSPoint p;
DPSmouselocation(GSCurrentContext(), &x, &y);
x -= frame.origin.x;
y -= frame.origin.y;
return NSMakePoint(x, y);
DPSmouselocation(GSCurrentContext(), &p.x, &p.y);
p = [self convertScreenToBase: p];
return p;
}
- (NSEvent*) nextEventMatchingMask: (unsigned int)mask
@ -2475,7 +2517,7 @@ resetCursorRectsForView(NSView *theView)
}
}
- (BOOL) tryToPerform: (SEL)anAction with: anObject
- (BOOL) tryToPerform: (SEL)anAction with: (id)anObject
{
// FIXME: On NO we should hand it on to the delegate
return ([super tryToPerform: anAction with: anObject]);
@ -3272,4 +3314,3 @@ NSWindow* GSWindowWithNumber(int num)
}