// // Conversation.m // Proteus // // Created by Julian Cain on 7/26/10. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "Conversation.h" @implementation Conversation @synthesize name = _name; @synthesize webView = _webView; - (void)initWebView { self.webView = [[[WebView alloc] initWithFrame:NSZeroRect] autorelease]; self.webView.autoresizingMask = NSViewMinXMargin | NSViewMinYMargin | NSViewMaxXMargin | NSViewMaxYMargin | NSViewWidthSizable | NSViewHeightSizable ; self.webView.policyDelegate = self; self.webView.UIDelegate = self; self.webView.frameLoadDelegate = self; [self.webView setMaintainsBackForwardList:NO]; [self loadWebView]; } - (void)loadWebView { NSString * basePath = [NSString stringWithFormat:@"%@/Default.chatstyle", [[NSBundle mainBundle] builtInPlugInsPath] ]; if (![[NSFileManager defaultManager] fileExistsAtPath:basePath]) { NSAssert(0, @"Plugin directory not found."); } NSString * familyName = [[NSFont systemFontOfSize:12.0f] familyName]; [[self.webView preferences] setStandardFontFamily:familyName]; [[self.webView preferences] setFixedFontFamily:familyName]; [[self.webView preferences] setSerifFontFamily:familyName]; [[self.webView preferences] setSansSerifFontFamily:familyName]; [[self.webView preferences] setDefaultFontSize:12.0f]; [[self.webView preferences] setDefaultFixedFontSize:12.0f]; [[self.webView preferences] setMinimumFontSize:1]; [[self.webView preferences] setMinimumLogicalFontSize:1]; NSString * baseUrl = [NSString stringWithFormat:@"file://%@/", basePath]; NSString * path = [NSString stringWithFormat:@"%@/ChatTemplate.html", [ [NSBundle mainBundle] builtInPlugInsPath] ]; NSData * data = [[NSData alloc] initWithContentsOfFile:path]; NSString * template = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding ]; [data release]; path = [NSString stringWithFormat:@"%@/header.html", basePath]; data = [[NSData alloc] initWithContentsOfFile: path]; NSString *header = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding ]; [data release]; path = [NSString stringWithFormat:@"%@/footer.html", basePath]; data = [[NSData alloc] initWithContentsOfFile:path]; NSString *footer = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding ]; [data release]; path = [NSString stringWithFormat: @"%@/Info.plist", basePath]; NSString * html = [NSString stringWithFormat:template, baseUrl, [NSString stringWithFormat:@"variants/Blue vs Gray.css"], header, footer ]; [[self.webView mainFrame] loadHTMLString:html baseURL:nil]; [template release]; [header release]; [footer release]; } - (void)dealloc { [_name release], _name = 0; [_webView release], _webView = 0; [super dealloc]; } @end