Mailing Lists: Apple Mailing Lists

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

Re: Smooth Resizing (again)



John,

Thanks for your input, much appreciated, but a bit more help would be
needed for me to get it working.
I'm getting closer (I think) but obviously missing something.

So far I've created a Cocoa class and added the 2 files (.h and .m) in
the 'Resources' folder of my application.

File called 'CocoaUtilities.h' as the following:

#import <CocoaUtilities.h>

@interface CocoaUtilities : NSObject {

}

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

@end

Then I've got 'CocoaUtilities.m' which has the following:

#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

When I build the project I get the following errors:

> Compiling CocoaUtilities.m (4 errors)
 undefined type, found 'NSWindow'
 undefined type, found 'NSWindow'
 undefined type, found 'NSRect'
> In file included from CocoaUtilities.m:2:
 cannot find interface declaration for 'NSObject', superclass of
'CocoaUtilities'

In IB, all I've got is a NSWindow called 'Window' with the AS name of
"w_main" and a NSButton with the AS name of "b_resize". I think I'm
supposed to create some type of custom class somewhere, but it might as
well be in Chinese, I can't work this out.

>> Here's a post from the archives:
>> http://lists.apple.com/archives/applescript-studio/2002/Dec/21/
>> changingwindowsize.001.txt
>>
>> Anybody out there willing to explain to a Cocoa newbie how I get the
>> following to work in an AS Studio application?
>
> Make new Cocoa class files, calling them something like
> "CocoaUtilities".
> Put that method in the .m file, and change the "-" at the start of the
> method to a "+" (skip the import and implementation lines).
>
> Add the following to the .h file
> + (void)resizeWindow :(NSWindow *)window toHeight :(int)height
> toWidth:(int)width;
>
>
> In AppleScript, call the method with:
>
> Call method "resizeWindow:toHeight:toWidth:" of class "CocoaUtilities"
> with
> parameters { theWindowReference, 100, 200}
>
> Think that should do it...
>
> JT
>
>
>
>>
>> // Thanks to Jan Van Boghout for this code, from his demo app
>> "SmoothResize"
>>
>> #import "Application.h"
>>
>> @implementation NSApplication (ApplicationName)
>>
>> - (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(windowFr
>> am
>> e) - height,width,height) styleMask:[window styleMask]];
>>
>> [window setFrame:newWindowFrame display:YES animate:YES];
>> }
>>
>> @end
>>
>> Next, to call on this, use the following syntax:
>>
>> call method "resizeWindow:toHeight:toWidth:" with parameters {window
>> "theWindow", Y, X}
>> [/quote]
>>
>
>
>
--
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.

References: 
 >Re: Smooth Resizing (again) (From: John Timmer <email@hidden>)



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.