Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Resize NSImageView



Hi all,
Is there a one liner or anything simple to add to the below code that
will automatically resize a NSImageView "preview" to the size of window
"w_main" as this window is resized on a call method? The initial size
of NSImageView is 200x200, the same as the window.

set {w_height, w_width} to {400, 400}
call method "resizeWindow:toHeight:toWidth:" of class "CocoaUtilities"
with parameters {window "w_main", w_height, w_width}

CocoaUtilities.h contains:

#import <Cocoa/Cocoa.h>

@interface CocoaUtilities : NSObject {

}

+ (void)resizeWindow :(NSWindow *)window toHeight :(int)height
toWidth:(int)width;

@end

CocoaUtilities.m contains:

#import "CocoaUtilities.h"

@implementation CocoaUtilities

+ (void)resizeWindow :(NSWindow *)window toHeight :(int)height toWidth
:(int)width
{
NSRect windowFrame,newWindowFrame;
windowFrame = [NSWindow contentRectForFrameRect:[window frame]
styleMask:[window styleMask]];
newWindowFrame = [NSWindow
frameRectForContentRect:NSMakeRect(NSMinX(windowFrame),NSMaxY(windowFram
e) - height,width,height) styleMask:[window styleMask]];

[window setFrame:newWindowFrame display:YES animate:YES];
}

@end

Any help much appreciated.

--
autoMAC-it
mailto:email@hidden
visit: http://www.dizzypenguin.com/automac-it/
_______________________________________________
applescript-studio mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-studio
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.