5 // Created by Evan Schoenberg on 12/26/05.
8 #import "AIMessageWindow.h"
9 #import "AIClickThroughThemeDocumentButton.h"
10 #import <AIUtilities/AIApplicationAdditions.h>
11 #import "AIMessageWindowController.h"
12 #import "AIInterfaceControllerProtocol.h"
15 * @class AIMessageWindow
16 * @brief This AIDockingWindow subclass serves message windows.
18 * It overrides the standardWindowButton:forStyleMask: class method to provide
19 * AIClickThroughThemeDocumentButton objects for NSWindowDocumentIconButton requests on 10.4 and earlier.
20 * Delegate methods in 10.5+ handle what we need.
22 @implementation AIMessageWindow
24 - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
26 if (!(self = [super initWithContentRect:contentRect styleMask:styleMask backing:bufferingType defer:deferCreation]))
28 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scriptedWindowDidClose:) name:NSWindowWillCloseNotification object:nil];
33 * @brief Return the standard window button for a mask
35 * We return AIClickThroughThemeDocumentButton instead of NSThemeDocumentButton to provide
36 * click-through dragging behavior on 10.4 and earlier.
38 + (NSButton *)standardWindowButton:(NSWindowButton)button forStyleMask:(unsigned int)styleMask
40 NSButton *standardWindowButton = [super standardWindowButton:button forStyleMask:styleMask];
42 if (![NSApp isOnLeopardOrBetter]) {
43 if (button == NSWindowDocumentIconButton) {
44 [NSKeyedArchiver setClassName:@"AIClickThroughThemeDocumentButton" forClass:[NSThemeDocumentButton class]];
45 standardWindowButton = [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:standardWindowButton]];
47 [[standardWindowButton retain] autorelease];
51 return standardWindowButton;
54 - (NSScriptObjectSpecifier *)objectSpecifier
56 NSScriptClassDescription *containerClassDesc = (NSScriptClassDescription *)[NSScriptClassDescription classDescriptionForClass:[NSApp class]];
57 return [[NSUniqueIDSpecifier alloc]
58 initWithContainerClassDescription:containerClassDesc
59 containerSpecifier:nil key:@"chatWindows"
60 uniqueID:[NSValue valueWithPointer:self]];
65 return [(AIMessageWindowController *)[self windowController] containedChats];
68 - (id)handleCloseScriptCommand:(NSCloseCommand *)command
70 [command suspendExecution];
71 rememberedScriptCommand = command;
73 //get a list of all the chats in this window
74 NSArray *chatsInThisWindow = [self chats];
75 for (int i=[chatsInThisWindow count]-1;i>=0;i--)
76 [[[AIObject sharedAdiumInstance] interfaceController] closeChat:[chatsInThisWindow objectAtIndex:i]];
79 - (void)scriptedWindowDidClose:(NSNotification *)notification
81 [rememberedScriptCommand resumeExecutionWithResult:nil];
82 rememberedScriptCommand = nil;