Hoping someone can steer me in the right direction.  I'm not very good with 
Objective-C, but I'm trying to view an EPS image within a scroll window.  When 
making the window bigger, I'd like the EPS to enlarge.  For example, I'd like 
the width of the EPS to show in the scroll window and when the window is made 
bigger then the EPS will enlarge.  The user could then scroll down to see the 
rest of the image.  I'd like it to work similar to how the PDFKit displays PDF 
images in it's scroll view.

I started off by dragging an 'Object' controller to the 'MainMenu.xib' window 
and then setting it's class to appController.  I then drug a 'scroll view' from 
the library into my 'MainMenu.xib' window.  When I double click on that I get a 
window titled 'Bordered Scroll View (Custom View)' and it has the word 'Custom 
View' inside the window itself.  Ultimately, I'm going to display this scroll 
view within a 'Box' so I can switch views easily.  Next I Control-dragged from 
the appController (in the 'MainMenu.xib' window) to the center of the 'Bordered 
Scroll View' window (where it says 'Custom View') and I selected "theView".  
Then I Control-dragged from the appController (in the 'MainMenu.xib' window) to 
the 'Bordered Scroll View' (in the 'MainMenu.xib' window) and selected 
"scrollView".  I connected the 'box' appropriately as well.  In my .h file I 
have:

IBOutlet NSScrollView *scrollView;
IBOutlet NSView *theView;
IBOutlet NSBox *theBox;

In my .m file I have:

---------------
if ([ext isEqualToString:@"EPS"]) {
        NSImage *theImage = [[NSImage alloc] initWithContentsOfFile:filePath];
        [theImage drawInRect:NSMakeRect(0.0, 0.0, [theImage size].width, 
[theImage size].height) fromRect:NSZeroRect operation:NSCompositeSourceOver 
fraction:1.0];
}
---------------

but it only displays part of the EPS image outside the scroll window.  I've 
also been researching 'dataWithEPSInsideRect' but I'm pretty lost:

---------------
if ([ext isEqualToString:@"EPS"]) {
        NSData *theData = [theView dataWithEPSInsideRect:[theView bounds]];
        NSEPSImageRep *epsRep = [NSEPSImageRep imageRepWithData:theData];
        NSImage *epsImage = [[NSImage alloc] initWithSize:[theView 
bounds].size];
        [epsImage addRepresentation:epsRep];
        [theView setContentView:epsImage];
        [theBox setContentView:scrollView];
}
---------------

I'd appreciate any thoughts or if you could point me to a web-site that 
discusses this possibility further.

Thanks.

Jay
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to