Initial implementation of NSScreen.

Add mouse dragged events for mouse tracking.
Implement methods for converting points to/from views.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@1638 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
gnustep 1996-06-21 15:27:13 +00:00
parent d4848b7da2
commit acbe822337
10 changed files with 139 additions and 25 deletions

View file

@ -449,6 +449,53 @@ NSString *NSViewFocusChangedNotification;
//
// Converting Coordinates
//
- (NSRect)convertRectToWindow:(NSRect)r
{
NSRect f, t, a;
id s;
a = r;
f = [self frame];
s = [self superview];
// climb up the superview chain
while (s)
{
t = [s frame];
// translate frame
f.origin.x += t.origin.x;
f.origin.y += t.origin.y;
s = [s superview];
}
a.origin.x += f.origin.x;
a.origin.y += f.origin.y;
return a;
}
- (NSPoint)convertPointToWindow:(NSPoint)p
{
NSRect f, t;
NSPoint a;
id s;
a = p;
f = [self frame];
s = [self superview];
// climb up the superview chain
while (s)
{
t = [s frame];
// translate frame
f.origin.x += t.origin.x;
f.origin.y += t.origin.y;
s = [s superview];
}
a.x += f.origin.x;
a.y += f.origin.y;
return a;
}
- (NSRect)centerScanRect:(NSRect)aRect
{
return NSZeroRect;
@ -457,18 +504,59 @@ NSString *NSViewFocusChangedNotification;
- (NSPoint)convertPoint:(NSPoint)aPoint
fromView:(NSView *)aView
{
return NSZeroPoint;
NSPoint p, q;
NSRect r;
// Must belong to the same window
if (([self window] != [aView window]) && (aView))
return NSZeroPoint;
// if aView is nil
// then converting from window
// so convert from the content from the content view of the window
if (aView == nil)
return [self convertPoint: aPoint fromView:[[self window] contentView]];
// Convert the point to window coordinates
p = [aView convertPointToWindow: aPoint];
// Convert out origin to window coordinates
q = [self convertPointToWindow: bounds.origin];
NSLog(@"point convert: %f %f %f %f\n", p.x, p.y, q.x, q.y);
// now translate
p.x -= q.x;
p.y -= q.y;
return p;
}
- (NSPoint)convertPoint:(NSPoint)aPoint
toView:(NSView *)aView
{
NSPoint p;
NSPoint p, q;
NSRect r;
// Must belong to the same window
if (([self window] != [aView window]) && (aView))
return NSZeroPoint;
// if aView is nil
// then converting to window
if (aView == nil)
return [self convertPointToWindow: aPoint];
// convert everything to window coordinates
p = [self convertPointToWindow: aPoint];
r = [aView bounds];
q = [aView convertPointToWindow: r.origin];
NSLog(@"point convert: %f %f %f %f\n", p.x, p.y, q.x, q.y);
// now translate
p.x -= q.x;
p.y -= q.y;
return p;
}