comparison mac/dw.m @ 954:cfb12bf3bb06

Fixes for some more coordinate system issues on the Mac. Also some changes to the test program to make sure to test for these type issues.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 02 May 2011 01:07:49 +0000
parents 2dfc06afc7d3
children beed3e7f9d4b
comparison
equal deleted inserted replaced
953:2dfc06afc7d3 954:cfb12bf3bb06
273 else if(type == NSOtherMouseDown || type == NSOtherMouseUp) 273 else if(type == NSOtherMouseDown || type == NSOtherMouseUp)
274 { 274 {
275 button = 3; 275 button = 3;
276 } 276 }
277 277
278 return buttonfunc(object, (int)p.x, (int)[object frame].size.height - p.y, button, handler->data); 278 return buttonfunc(object, (int)p.x, (int)p.y, button, handler->data);
279 } 279 }
280 /* Motion notify event */ 280 /* Motion notify event */
281 case 5: 281 case 5:
282 { 282 {
283 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; 283 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
288 if(DWOSMinor < 6) 288 if(DWOSMinor < 6)
289 { 289 {
290 buttonmask = (1 << [event buttonNumber]); 290 buttonmask = (1 << [event buttonNumber]);
291 } 291 }
292 292
293 return motionfunc(object, (int)p.x, (int)[object frame].size.height - p.y, buttonmask, handler->data); 293 return motionfunc(object, (int)p.x, (int)p.y, buttonmask, handler->data);
294 } 294 }
295 /* Window close event */ 295 /* Window close event */
296 case 6: 296 case 6:
297 { 297 {
298 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; 298 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
501 else 501 else
502 { 502 {
503 image = [[NSImage alloc] initWithSize:[rep size]]; 503 image = [[NSImage alloc] initWithSize:[rep size]];
504 [image addRepresentation:rep]; 504 [image addRepresentation:rep];
505 } 505 }
506 // make a new transform:
507 NSAffineTransform *t = [NSAffineTransform transform];
508
509 // by scaling Y negatively, we effectively flip the image:
510 [t scaleXBy:1.0 yBy:-1.0];
511
512 // but we also have to translate it back by its height:
513 [t translateXBy:0.0 yBy:-[rep size].height];
514
515 // apply the transform:
516 [t concat];
517 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height) 506 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height)
518 operation:NSCompositeSourceOver fraction:1.0]; 507 operation:NSCompositeSourceOver fraction:1.0];
519 [bltsrc release]; 508 [bltsrc release];
520 [image release]; 509 [image release];
521 } 510 }
732 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); } 721 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); }
733 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } 722 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); }
734 -(void)mouseDragged:(NSEvent *)theEvent { _event_handler(self, theEvent, 5); } 723 -(void)mouseDragged:(NSEvent *)theEvent { _event_handler(self, theEvent, 5); }
735 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); } 724 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); }
736 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); } 725 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); }
737 -(BOOL)isFlipped { return NO; } 726 -(BOOL)isFlipped { return YES; }
738 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [font release]; [super dealloc]; } 727 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [font release]; [super dealloc]; }
739 -(BOOL)acceptsFirstResponder { return YES; } 728 -(BOOL)acceptsFirstResponder { return YES; }
740 @end 729 @end
741 730
742 /* Subclass for a top-level window */ 731 /* Subclass for a top-level window */