Browse files

replaced ZoomedWindowDelegate

darcs-hash:20060716231007-f3188-ce8179d0f64b7c8d80c802a0577ef2074eb9f8bd.gz
  • Loading branch information...
1 parent 0cd5c1c commit 54db85022a036dc7cfb27a6c3f4d2c7e7bf36a30 @ianh ianh committed Jul 16, 2006
Showing with 33 additions and 105 deletions.
  1. +1 −0 ZoomableWindow.h
  2. +32 −15 ZoomableWindow.m
  3. +0 −20 ZoomedWindowDelegate.h
  4. +0 −64 ZoomedWindowDelegate.m
  5. +0 −6 megazoomer.xcodeproj/project.pbxproj
View
1 ZoomableWindow.h
@@ -18,6 +18,7 @@
- (BOOL)isMegaZoomable;
- (BOOL)isBig;
+- (BOOL)isGettingBig;
- (void)megaZoom;
- (void)returnToOriginal;
View
47 ZoomableWindow.m
@@ -8,10 +8,13 @@
#import "MegaZoomer.h"
#import "ZoomableWindow.h"
-#import "ZoomedWindowDelegate.h"
#import <Carbon/Carbon.h>
#import <objc/objc-class.h>
+#define NOT_BIG 0
+#define GETTING_BIG 1
+#define TOTALLY_BIG 2
+
static NSMutableDictionary *bignesses = nil;
static NSMutableDictionary *originalFrames = nil;
static NSMutableDictionary *originalBackgroundMovabilities = nil;
@@ -25,36 +28,48 @@ - (BOOL)__appkit_validateMenuItem:(NSMenuItem *)item;
- (void)__appkit_zoom:sender;
- (void)__appkit_performZoom:sender;
- (void)__appkit_toggleToolbarShown:sender;
+- (void)__appkit_setFrame:(NSRect)windowFrame display:(BOOL)displayViews;
+- (void)__appkit_close;
@end
@implementation NSWindow(ZoomableWindow)
+- (void)__megazoomer_close
+{
+ if ([self isBig]) {
+ [self returnToOriginal];
+ }
+ [self __appkit_close];
+}
+
+- (void)__megazoomer_setFrame:(NSRect)windowFrame display:(BOOL)displayViews
+{
+ if (![self isBig]) {
+ [self __appkit_setFrame:windowFrame display:displayViews];
+ }
+}
+
- (NSRect)__megazoomer_constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
{
- if ([self isBig]) {
+ if ([self isBig] || [self isGettingBig]) {
return [self megaZoomedFrame];
} else {
return [self __appkit_constrainFrameRect:frameRect toScreen:screen];
}
}
-- (void)setBig:(BOOL)big
+- (void)setBig:(int)big
{
if (!bignesses) {
bignesses = [[NSMutableDictionary alloc] init];
}
- [bignesses setObject:[NSNumber numberWithBool:big] forKey:[NSNumber numberWithInt:[self windowNumber]]];
+ [bignesses setObject:[NSNumber numberWithInt:big] forKey:[NSNumber numberWithInt:[self windowNumber]]];
}
- (void)returnToOriginal
{
NSRect originalFrame = [[originalFrames objectForKey:[NSNumber numberWithInt:[self windowNumber]]] rectValue];
- id fakeDelegate = [self delegate];
- if ([fakeDelegate respondsToSelector:@selector(realDelegate)]) {
- [self setDelegate:[fakeDelegate realDelegate]];
- [fakeDelegate release];
- }
- [self setBig:NO];
+ [self setBig:NOT_BIG];
[self setShowsResizeIndicator:YES];
[self setFrame:originalFrame display:YES animate:YES];
[self setMovableByWindowBackground:[[originalBackgroundMovabilities objectForKey:[NSNumber numberWithInt:[self windowNumber]]] boolValue]];
@@ -137,13 +152,11 @@ - (void)megaZoom
}
[originalBackgroundMovabilities setObject:[NSNumber numberWithBool:[self isMovableByWindowBackground]] forKey:[NSNumber numberWithInt:[self windowNumber]]];
- [self setBig:YES];
+ [self setBig:GETTING_BIG];
[self setShowsResizeIndicator:NO];
[self setFrame:[self megaZoomedFrame] display:YES animate:YES];
[self setMovableByWindowBackground:NO];
-
- id realDelegate = [self delegate];
- [self setDelegate:[[ZoomedWindowDelegate alloc] initWithRealDelegate:realDelegate]];
+ [self setBig:TOTALLY_BIG];
}
- (void)toggleMegaZoom
@@ -157,7 +170,11 @@ - (void)toggleMegaZoom
- (BOOL)isBig
{
- return [[bignesses objectForKey:[NSNumber numberWithInt:[self windowNumber]]] boolValue];
+ return [[bignesses objectForKey:[NSNumber numberWithInt:[self windowNumber]]] intValue] == TOTALLY_BIG;
+}
+- (BOOL)isGettingBig
+{
+ return [[bignesses objectForKey:[NSNumber numberWithInt:[self windowNumber]]] intValue] == GETTING_BIG;
}
+ (BOOL)anyBig
View
20 ZoomedWindowDelegate.h
@@ -1,20 +0,0 @@
-//
-// ZoomedWindowDelegate.h
-// megazoomer
-//
-// Created by Ian Henderson on 24 Mar 06.
-// Copyright 2006 Ian Henderson. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-
-
-@interface ZoomedWindowDelegate : NSObject {
- id realDelegate;
-}
-
-- (id)initWithRealDelegate:(id)delegate;
-
-- (id)realDelegate;
-
-@end
View
64 ZoomedWindowDelegate.m
@@ -1,64 +0,0 @@
-//
-// ZoomedWindowDelegate.m
-// megazoomer
-//
-// Created by Ian Henderson on 24 Mar 06.
-// Copyright 2006 Ian Henderson. All rights reserved.
-//
-
-#import "ZoomedWindowDelegate.h"
-#import "ZoomableWindow.h"
-
-
-@implementation ZoomedWindowDelegate
-
-- (id)initWithRealDelegate:(id)delegate
-{
- if ([super init] == nil) {
- return nil;
- }
- realDelegate = delegate;
- return self;
-}
-
-- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize
-{
- return [sender frame].size;
-}
-
-- (void)windowWillClose:(NSNotification *)aNotification
-{
- if ([realDelegate respondsToSelector:@selector(windowWillClose:)]) {
- [realDelegate windowWillClose:aNotification];
- }
- NSWindow *window = [aNotification object];
- [window returnToOriginal];
- // "self" is dead at this point, so don't add anything here
-}
-
-- (id)realDelegate
-{
- return realDelegate;
-}
-
-- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
-{
- NSMethodSignature *methodSignature = [super methodSignatureForSelector:aSelector];
- if (methodSignature == nil) {
- methodSignature = [realDelegate methodSignatureForSelector:aSelector];
- }
- return methodSignature;
-}
-
-- (void)forwardInvocation:(NSInvocation *)invocation
-{
- SEL aSelector = [invocation selector];
-
- if ([realDelegate respondsToSelector:aSelector]) {
- [invocation invokeWithTarget:realDelegate];
- } else {
- [super forwardInvocation:invocation];
- }
-}
-
-@end
View
6 megazoomer.xcodeproj/project.pbxproj
@@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
- BF0FDD1D09D4DF6E004C9060 /* ZoomedWindowDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = BF0FDD1C09D4DF6E004C9060 /* ZoomedWindowDelegate.m */; };
BFED0C9A08E0DBA80038121C /* MegaZoomer.m in Sources */ = {isa = PBXBuildFile; fileRef = BFED0C9908E0DBA80038121C /* MegaZoomer.m */; };
BFED0CF208E0E9C70038121C /* ZoomableWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = BFED0CF108E0E9C70038121C /* ZoomableWindow.m */; };
BFF5568B09D4D49100CC32BF /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BFF5568A09D4D49100CC32BF /* Carbon.framework */; };
@@ -47,8 +46,6 @@
32DBCF630370AF2F00C91783 /* megazoomer_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = megazoomer_Prefix.pch; sourceTree = "<group>"; };
8D5B49B6048680CD000E48DA /* megazoomer.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = megazoomer.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
- BF0FDD1B09D4DF6E004C9060 /* ZoomedWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZoomedWindowDelegate.h; sourceTree = "<group>"; };
- BF0FDD1C09D4DF6E004C9060 /* ZoomedWindowDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZoomedWindowDelegate.m; sourceTree = "<group>"; };
BFED0C9808E0DBA80038121C /* MegaZoomer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MegaZoomer.h; sourceTree = "<group>"; };
BFED0C9908E0DBA80038121C /* MegaZoomer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = MegaZoomer.m; sourceTree = "<group>"; };
BFED0CF008E0E9C70038121C /* ZoomableWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZoomableWindow.h; sourceTree = "<group>"; };
@@ -108,8 +105,6 @@
BFED0C9908E0DBA80038121C /* MegaZoomer.m */,
BFED0CF008E0E9C70038121C /* ZoomableWindow.h */,
BFED0CF108E0E9C70038121C /* ZoomableWindow.m */,
- BF0FDD1B09D4DF6E004C9060 /* ZoomedWindowDelegate.h */,
- BF0FDD1C09D4DF6E004C9060 /* ZoomedWindowDelegate.m */,
);
name = Classes;
sourceTree = "<group>";
@@ -221,7 +216,6 @@
files = (
BFED0C9A08E0DBA80038121C /* MegaZoomer.m in Sources */,
BFED0CF208E0E9C70038121C /* ZoomableWindow.m in Sources */,
- BF0FDD1D09D4DF6E004C9060 /* ZoomedWindowDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

0 comments on commit 54db850

Please sign in to comment.