Revision: 3225 http://skim-app.svn.sourceforge.net/skim-app/?rev=3225&view=rev Author: hofman Date: 2007-11-20 01:35:35 -0800 (Tue, 20 Nov 2007)
Log Message: ----------- Implement our custom zoom actions in snapshot controller. Modified Paths: -------------- trunk/SKSnapshotWindowController.h trunk/SKSnapshotWindowController.m Modified: trunk/SKSnapshotWindowController.h =================================================================== --- trunk/SKSnapshotWindowController.h 2007-11-19 16:40:42 UTC (rev 3224) +++ trunk/SKSnapshotWindowController.h 2007-11-20 09:35:35 UTC (rev 3225) @@ -39,10 +39,10 @@ #import <Cocoa/Cocoa.h> [EMAIL PROTECTED] PDFView, PDFDocument, PDFPage; [EMAIL PROTECTED] BDSKZoomablePDFView, PDFDocument, PDFPage; @interface SKSnapshotWindowController : NSWindowController { - IBOutlet PDFView* pdfView; + IBOutlet BDSKZoomablePDFView* pdfView; NSImage *thumbnail; id delegate; BOOL miniaturizing; Modified: trunk/SKSnapshotWindowController.m =================================================================== --- trunk/SKSnapshotWindowController.m 2007-11-19 16:40:42 UTC (rev 3224) +++ trunk/SKSnapshotWindowController.m 2007-11-20 09:35:35 UTC (rev 3225) @@ -309,6 +309,53 @@ return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:[self pageIndex]], PAGE_KEY, NSStringFromRect(rect), RECT_KEY, [NSNumber numberWithFloat:[pdfView scaleFactor]], SCALE_FACTOR_KEY, [NSNumber numberWithBool:autoFits], AUTO_FITS_KEY, [NSNumber numberWithBool:[[self window] isVisible]], HAS_WINDOW_KEY, nil]; } +#pragma mark Actions + +- (IBAction)doZoomIn:(id)sender { + [pdfView zoomIn:sender]; +} + +- (IBAction)doZoomOut:(id)sender { + [pdfView zoomOut:sender]; +} + +- (IBAction)doZoomToPhysicalSize:(id)sender { + float scaleFactor = 1.0; + NSScreen *screen = [[self window] screen]; + CGDirectDisplayID displayID = (CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; + CGSize physicalSize = CGDisplayScreenSize(displayID); + NSSize resolution = [[[screen deviceDescription] objectForKey:NSDeviceResolution] sizeValue]; + + if (CGSizeEqualToSize(physicalSize, CGSizeZero) == NO) + scaleFactor = CGDisplayPixelsWide(displayID) * 25.4f / (physicalSize.width * resolution.width); + [pdfView setScaleFactor:scaleFactor]; +} + +- (IBAction)doZoomToActualSize:(id)sender { + [pdfView setScaleFactor:1.0]; +} + +- (IBAction)toggleAutoScale:(id)sender { + [pdfView setAutoFits:[pdfView autoFits] == NO]; +} + +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem { + SEL action = [menuItem action]; + if (action == @selector(doZoomIn:)) { + return [pdfView canZoomIn]; + } else if (action == @selector(doZoomOut:)) { + return [pdfView canZoomOut]; + } else if (action == @selector(doZoomToActualSize:)) { + return fabsf([pdfView scaleFactor] - 1.0 ) > 0.01; + } else if (action == @selector(doZoomToPhysicalSize:)) { + return YES; + } else if (action == @selector(toggleAutoScale:)) { + [menuItem setState:[pdfView autoFits] ? NSOnState : NSOffState]; + return YES; + } + return YES; +} + #pragma mark Thumbnails - (NSImage *)thumbnailWithSize:(float)size { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit