|
I've made some changes to avoid warnings at compile time, improve image scaling, and avoid memory leaks.
I - To avoid warning at compile time:
1 - Warning: IAWindoController does not respond to scaleImageTo
Added in IAWindowController.h the declaration of:
- (void)scaleImageTo:(float)_scale;
2 - Warnings: cannot find method
return type for 'activeImage' defaults to id
Added in IAWindowController.m:
#import "MyDocument.h"
II - To avoid incorrect redrawing of image when scaling (image drawn over scrollers)
1 - Change in (void) scaleFrameBy: (float) scale in IAImageView.m
Replace: [self setNeedsDisplay: YES];
by: [[[self window] contentView] displayIfNeededIgnoringOpacity];
As the scrollers are opaque, we need to force a complete redraw.
2 - Add in (void) validateScrollers in IAImageView.m
at the very end: [scrollView tile];
Forces a redraw of scrollView, clipView, scrollers, and ImageView taking into account the opacity (does not redraw the opaque parts).
III - To avoid memory leaks
1 - Add
[windowController release];
at the end of - (void)makeWindowControllers in MyDocumemt.h
2 - Change - (BOOL) loadDataRepresentation: (NSData *) data ofType: (NSString *) aType in MyDocument.h
- (BOOL) loadDataRepresentation: (NSData *) data ofType: (NSString *) aType
{
activeImage = [[[NSImage alloc] initWithData: data] autorelease];
return (activeImage != nil);
}
|
[self setNeedsDisplay: YES];
to
[[[self superview] superview] setNeedsDisplay:YES];
The problem we had was that the original line just refreshes the imageview, so the scroll bars are being refreshed and therefore don't go away when they should. The new line sets the entire scrollview to be refreshed, which is exactly what we want.