Mercurial > dwindows
changeset 665:e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 26 Feb 2011 03:17:12 +0000 |
parents | ba3af8eb56f1 |
children | e426de6e6c7c |
files | mac/dw.m |
diffstat | 1 files changed, 56 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/mac/dw.m Fri Feb 25 21:12:02 2011 +0000 +++ b/mac/dw.m Sat Feb 26 03:17:12 2011 +0000 @@ -180,7 +180,7 @@ dw_pointer_query_pos(&x, &y); - return containercontextfunc(handler->window, text, x, y, handler->data, user); + return containercontextfunc(handler->window, text, (int)x, (int)y, handler->data, user); } case 12: { @@ -577,7 +577,7 @@ { if(tvcols && data) { - int cols = [tvcols count]; + int cols = (int)[tvcols count]; if(cols) { return [data count] / cols; @@ -590,7 +590,7 @@ if(tvcols) { int z, col = -1; - int count = [tvcols count]; + int count = (int)[tvcols count]; for(z=0;z<count;z++) { @@ -602,7 +602,7 @@ } if(col != -1) { - int index = (aRow * count) + col; + int index = (int)(aRow * count) + col; id this = [data objectAtIndex:index]; return ([this isKindOfClass:[NSNull class]]) ? nil : this; } @@ -614,7 +614,7 @@ if(tvcols) { int z, col = -1; - int count = [tvcols count]; + int count = (int)[tvcols count]; for(z=0;z<count;z++) { @@ -626,7 +626,7 @@ } if(col != -1) { - int index = (rowIndex * count) + col; + int index = (int)(rowIndex * count) + col; [data replaceObjectAtIndex:index withObject:anObject]; } } @@ -634,15 +634,15 @@ -(void *)userdata { return userdata; } -(void)setUserdata:(void *)input { userdata = input; } -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } --(int)addRow:(NSArray *)input { if(data) { [data addObjectsFromArray:input]; [titles addPointer:NULL]; return [titles count]; } return 0; } +-(int)addRow:(NSArray *)input { if(data) { [data addObjectsFromArray:input]; [titles addPointer:NULL]; return (int)[titles count]; } return 0; } -(int)addRows:(int)number { if(tvcols) { - int count = number * [tvcols count]; + int count = (int)number * [tvcols count]; int z; - lastAddPoint = [titles count]; + lastAddPoint = (int)[titles count]; for(z=0;z<count;z++) { @@ -652,7 +652,7 @@ { [titles addPointer:NULL]; } - return [titles count]; + return (int)[titles count]; } return 0; } @@ -660,7 +660,7 @@ { if(tvcols && input) { - int index = (row * [tvcols count]) + col; + int index = (int)(row * [tvcols count]) + col; [data replaceObjectAtIndex:index withObject:input]; } } @@ -669,7 +669,7 @@ if(tvcols) { int z, start, end; - int count = [tvcols count]; + int count = (int)[tvcols count]; start = count * row; end = start + count; @@ -700,13 +700,13 @@ } -(void)selectionChanged:(id)sender { - _event_handler(self, (NSEvent *)[self getRowTitle:[self selectedRow]], 12); + _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 12); } -(NSMenu *)menuForEvent:(NSEvent *)event { int row; NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; - row = [self rowAtPoint:where]; + row = (int)[self rowAtPoint:where]; _event_handler(self, (NSEvent *)[self getRowTitle:row], 10); return nil; } @@ -1500,13 +1500,13 @@ if(flags & DW_MB_ERROR) { - iResponse = + iResponse = (int) NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ], [ NSString stringWithUTF8String:outbuf ], button1, button2, button3); } else { - iResponse = + iResponse = (int) NSRunAlertPanel([ NSString stringWithUTF8String:title ], [ NSString stringWithUTF8String:outbuf ], button1, button2, button3); @@ -2339,7 +2339,7 @@ { DWComboBox *combo = handle; - return [combo numberOfItems]; + return (int)[combo numberOfItems]; } return 0; } @@ -2414,7 +2414,7 @@ if([object isMemberOfClass:[DWComboBox class]]) { DWComboBox *combo = handle; - return [combo indexOfSelectedItem]; + return (int)[combo indexOfSelectedItem]; } return -1; } @@ -2504,7 +2504,7 @@ { DWMLE *mle = handle; [mle insertText:[ NSString stringWithUTF8String:buffer ]]; - return strlen(buffer) + startpoint; + return (unsigned int)strlen(buffer) + startpoint; } /* @@ -2717,7 +2717,7 @@ { /* Create the File Save Dialog class. */ DWColorChoose *colorDlg = (DWColorChoose *)[DWColorChoose sharedColorPanel]; - NSColor *color = [[NSColor alloc] init]; + NSColor *color = [[[NSColor alloc] init] autorelease]; DWDialog *dialog = dw_dialog_new(colorDlg); /* Set defaults for the dialog. */ @@ -2751,10 +2751,13 @@ } NSBezierPath* aPath = [NSBezierPath bezierPath]; [aPath setLineWidth: 0.5]; - [[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]; + NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; + [color set]; + [color release]; [aPath moveToPoint:NSMakePoint(x, y)]; [aPath stroke]; + [aPath release]; [image unlockFocus]; } @@ -2782,11 +2785,14 @@ } NSBezierPath* aPath = [NSBezierPath bezierPath]; [aPath setLineWidth: 0.5]; - [[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]; + NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; + [color set]; + [color release]; [aPath moveToPoint:NSMakePoint(x1, y1)]; [aPath lineToPoint:NSMakePoint(x2, y2)]; [aPath stroke]; + [aPath release]; [image unlockFocus]; } @@ -2808,9 +2814,13 @@ if([image isMemberOfClass:[NSView class]]) { [image lockFocusIfCanDraw]; - [[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]; - NSDictionary *dict = [[NSDictionary alloc] init]; + NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; + NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: + /*[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,*/ + color, NSForegroundColorAttributeName, nil]; [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; + [dict release]; + [color release]; [image unlockFocus]; } _DWLastDrawable = handle; @@ -2824,8 +2834,11 @@ /*[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,*/ color, NSForegroundColorAttributeName, nil]; [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; + [dict release]; + [color release]; [image unlockFocus]; } + [nstr release]; } /* Query the width and height of a text string. @@ -2839,7 +2852,7 @@ 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 ]; + NSString *nstr = [[ NSString stringWithUTF8String:text ] autorelease]; if(pixmap) { image = (id)pixmap->handle; @@ -2851,6 +2864,7 @@ } NSDictionary *dict = [[NSDictionary alloc] init]; NSSize size = [nstr sizeWithAttributes:dict]; + [dict release]; if(width) { *width = size.width; @@ -2859,6 +2873,7 @@ { *height = size.height; } + [nstr release]; [image unlockFocus]; } @@ -2888,7 +2903,9 @@ } NSBezierPath* aPath = [NSBezierPath bezierPath]; [aPath setLineWidth: 0.5]; - [[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]; + NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; + [color set]; + [color release]; [aPath moveToPoint:NSMakePoint(*x, *y)]; for(z=1;z<npoints;z++) @@ -2901,6 +2918,7 @@ [aPath fill]; } [aPath stroke]; + [aPath release]; [image unlockFocus]; } @@ -2929,7 +2947,9 @@ } NSBezierPath* aPath = [NSBezierPath bezierPath]; [aPath setLineWidth: 0.5]; - [[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]; + NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; + [color set]; + [color release]; [aPath moveToPoint:NSMakePoint(x, y)]; [aPath lineToPoint:NSMakePoint(x, y + height)]; @@ -2938,6 +2958,7 @@ [aPath closePath]; [aPath fill]; [aPath stroke]; + [aPath release]; [image unlockFocus]; } @@ -3135,7 +3156,7 @@ NSTableColumn *column = [[NSTableColumn alloc] init]; [[column headerCell] setStringValue:[ NSString stringWithUTF8String:titles[z] ]]; [cont addTableColumn:column]; - [cont addColumn:column andType:flags[z]]; + [cont addColumn:column andType:(int)flags[z]]; } return TRUE; @@ -3683,7 +3704,7 @@ if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) return NULL; - NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; + NSData *thisdata = [[[NSData alloc] dataWithBytes:data length:len] autorelease]; NSImage *image = [[NSImage alloc] initWithData:thisdata]; NSSize size = [image size]; pixmap->width = size.width; @@ -4154,9 +4175,9 @@ unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) { DWNotebook *notebook = handle; - int page = [notebook pageid]; + NSInteger page = [notebook pageid]; DWNotebookPage *notepage = [[DWNotebookPage alloc] initWithIdentifier:nil]; - [notepage setPageid:(NSInteger)page]; + [notepage setPageid:page]; if(front) { [notebook insertTabViewItem:notepage atIndex:(NSInteger)0]; @@ -4406,10 +4427,10 @@ if([object isMemberOfClass:[NSWindow class]]) { NSWindow *window = object; - int currentstyle = [window styleMask]; + int currentstyle = (int)[window styleMask]; int tmp; - tmp = currentstyle | mask; + tmp = currentstyle | (int)mask; tmp ^= mask; tmp |= style; @@ -4849,7 +4870,7 @@ env->MajorBuild = env->MinorBuild = 0; - len = strlen(tempbuf); + len = (int)strlen(tempbuf); strcpy(env->buildDate, __DATE__); strcpy(env->buildTime, __TIME__); @@ -5147,7 +5168,7 @@ { if((message = _findsigmessage(signame)) != 0) { - _new_signal(message, window, msgid, sigfunc, data); + _new_signal(message, window, (int)msgid, sigfunc, data); } } }