# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1298605544 0 # Node ID eee90a788876c4af30c79a321bdd13186d0b46ca # Parent 2784e7ee8bcb0ce520d10928e61d991de9a5592a Added missing functions needed to build HandyFTP. Fixed render area rendering fonts upside down. diff -r 2784e7ee8bcb -r eee90a788876 mac/dw.m --- a/mac/dw.m Thu Feb 24 22:42:29 2011 +0000 +++ b/mac/dw.m Fri Feb 25 03:45:44 2011 +0000 @@ -84,7 +84,7 @@ int _event_handler(id object, NSEvent *event, int message) { SignalHandler *handler = _get_handler(object, message); - NSLog(@"Event handler - type %d\n", message); + /*NSLog(@"Event handler - type %d\n", message);*/ if(handler) { @@ -149,7 +149,6 @@ case 6: { int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; - NSLog(@"Close\n"); return closefunc(object, handler->data); } case 7: @@ -163,15 +162,13 @@ exp.width = rect.size.width; exp.height = rect.size.height; int result = exposefunc(object, &exp, handler->data); - NSGraphicsContext *gc = [[object window] graphicsContext]; - [gc flushGraphics]; + [[object window] flushWindow]; return result; } case 8: { int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; - NSLog(@"Clicked\n"); return clickfunc(object, handler->data); } case 10: @@ -214,6 +211,7 @@ #if !defined(GARBAGE_COLLECT) NSAutoreleasePool *pool; #endif +HWND _DWLastDrawable; /* So basically to implement our event handlers... * it looks like we are going to have to subclass @@ -516,7 +514,6 @@ -(void *)userdata; -(void)setUserdata:(void *)input; -(void)drawRect:(NSRect)rect; --(BOOL)isFlipped; -(void)mouseDown:(NSEvent *)theEvent; -(void)mouseUp:(NSEvent *)theEvent; @end @@ -525,7 +522,6 @@ -(void *)userdata { return userdata; } -(void)setUserdata:(void *)input { userdata = input; } -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); } --(BOOL)isFlipped { return YES; } -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); } -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } @end @@ -1149,6 +1145,7 @@ _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); (*depth)--; + [box setBox:_tmp]; } } @@ -1202,12 +1199,17 @@ Box box = [view box]; NSSize size = [view frame].size; _do_resize(&box, size.width, size.height); + [view setBox:box]; } } else if([handle isMemberOfClass:[DWRender class]]) { _event_handler(handle, nil, 1); } + else if([handle isMemberOfClass:[WebView class]]) + { + NSLog(@"x: %d y: %d width: %d height: %d", (int)point.x, (int)point.y, (int)size.width, (int)size.height); + } if(thisbox->type == DW_HORZ) currentx += width + vectorx + (pad * 2); @@ -1359,9 +1361,9 @@ #endif DWMainMenu = _generate_main_menu(); [DWApp setMainMenu:DWMainMenu]; - DWObject *test = [[DWObject alloc] init]; + /*DWObject *test = [[DWObject alloc] init]; NSThread *thread = [[ NSThread alloc] initWithTarget:test selector:@selector(uselessThread:) object:nil]; - [thread start]; + [thread start];*/ return 0; } @@ -2721,6 +2723,7 @@ else { [image lockFocusIfCanDraw]; + _DWLastDrawable = handle; } NSRect rect = NSMakeRect(x, y, x, y); [[NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] set]; @@ -2748,9 +2751,10 @@ else { [image lockFocusIfCanDraw]; + _DWLastDrawable = handle; } NSBezierPath* aPath = [NSBezierPath bezierPath]; - [aPath setLineWidth: 1.0]; + [aPath setLineWidth: 0.5]; [aPath moveToPoint:NSMakePoint(x1, y1)]; [aPath lineToPoint:NSMakePoint(x2, y2)]; @@ -2780,6 +2784,7 @@ [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; [image unlockFocus]; } + _DWLastDrawable = handle; } if(pixmap) { @@ -2802,11 +2807,27 @@ void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) { id image = handle; + NSString *nstr = [ NSString stringWithUTF8String:text ]; if(pixmap) { image = (id)pixmap->handle; + [image lockFocus]; } - NSLog(@"dw_font_text_extents_get() unimplemented\n"); + else + { + [image lockFocusIfCanDraw]; + } + NSDictionary *dict = [[NSDictionary alloc] init]; + NSSize size = [nstr sizeWithAttributes:dict]; + if(width) + { + *width = size.width; + } + if(height) + { + *height = size.height; + } + [image unlockFocus]; } /* Draw a polygon on a window (preferably a render window). @@ -2831,9 +2852,10 @@ else { [image lockFocusIfCanDraw]; + _DWLastDrawable = handle; } NSBezierPath* aPath = [NSBezierPath bezierPath]; - [aPath setLineWidth: 1.0]; + [aPath setLineWidth: 0.5]; [aPath moveToPoint:NSMakePoint(*x, *y)]; for(z=1;z