| 13 |
#import "TextFormatter.h" |
#import "TextFormatter.h" |
| 14 |
#import "LineTextFormatter.h" |
#import "LineTextFormatter.h" |
| 15 |
#import "MailTextFormatManager.h" |
#import "MailTextFormatManager.h" |
| 16 |
|
#import "IconedTextAttachmentCell.h" |
| 17 |
@implementation MainController |
@implementation MainController |
| 18 |
-(void)setupToolbar{ |
-(void)setupToolbar{ |
| 19 |
NSToolbar *toolbar; |
NSToolbar *toolbar; |
| 34 |
initWithMailBoxManager:mailBoxManager]; |
initWithMailBoxManager:mailBoxManager]; |
| 35 |
[folderTree setDataSource:ds]; |
[folderTree setDataSource:ds]; |
| 36 |
[self setupToolbar]; |
[self setupToolbar]; |
|
// addressBookView = [[[self addressBookController] addressBookView] retain]; |
|
|
// [addressBookDrawer setContentView:addressBookView]; |
|
| 37 |
composeControllers = [[NSMutableArray alloc] init]; |
composeControllers = [[NSMutableArray alloc] init]; |
| 38 |
|
myAddressBookController = [[self createAddressBookController] retain]; |
| 39 |
|
[myAddressBookController setWindowController:self]; |
| 40 |
|
|
| 41 |
[[mailContents textStorage] setDelegate:self]; |
[[mailContents textStorage] setDelegate:self]; |
| 42 |
mailTextFormatManager = [[MailTextFormatManager alloc] init]; |
mailTextFormatManager = [[MailTextFormatManager sharedMailTextFormatManager] retain]; |
|
[mailTextFormatManager addHeaderTextFormatter: |
|
|
[[TextFormatter alloc] initWithName:@"default" |
|
|
pattern:@"" |
|
|
foregroundColor:[NSColor blackColor] |
|
|
backgroundColor:[NSColor whiteColor] |
|
|
font:[NSFont fontWithName:@"HiraKakuPro-W3" size:13.0]]]; |
|
|
[mailTextFormatManager addContentsTextFormatter: |
|
|
[[TextFormatter alloc] initWithName:@"default" |
|
|
pattern:@"" |
|
|
foregroundColor:[NSColor blackColor] |
|
|
backgroundColor:[NSColor whiteColor] |
|
|
font:[NSFont fontWithName:@"HiraKakuPro-W3" size:12.0]]]; |
|
|
|
|
|
[mailTextFormatManager addContentsTextFormatter: |
|
|
[[LineTextFormatter alloc] initWithName:@"inyo" |
|
|
pattern:@">" |
|
|
foregroundColor:[NSColor colorWithCalibratedRed:0.0 |
|
|
green:0.8 |
|
|
blue:0.48 |
|
|
alpha:1.0] |
|
|
backgroundColor:[NSColor whiteColor] |
|
|
font:[NSFont fontWithName:@"HiraKakuPro-W3" size:12.0]]]; |
|
|
|
|
| 43 |
} |
} |
| 44 |
-(void)dealloc{ |
-(void)dealloc{ |
| 45 |
[window release]; |
[window release]; |
| 49 |
[mailContents release]; |
[mailContents release]; |
| 50 |
[mailBoxManager release]; |
[mailBoxManager release]; |
| 51 |
[prefController release]; |
[prefController release]; |
| 52 |
[addressbookController release]; |
[myAddressBookController release]; |
| 53 |
[mailTextFormatManager release]; |
[mailTextFormatManager release]; |
| 54 |
[super dealloc]; |
[super dealloc]; |
| 55 |
} |
} |
| 56 |
|
// メインウィンドウをNSWindowController化する前の一時措置 |
| 57 |
|
-(NSWindow *)window{ |
| 58 |
|
return window; |
| 59 |
|
} |
| 60 |
-(BOOL)windowShouldClose:(id)sender{ |
-(BOOL)windowShouldClose:(id)sender{ |
| 61 |
NSLog(@"window close!"); |
NSLog(@"window close!"); |
| 62 |
[composeControllers removeObject:[sender windowController]]; |
[composeControllers removeObject:[sender windowController]]; |
| 72 |
[tableColumn setDataCell:iconedCell]; |
[tableColumn setDataCell:iconedCell]; |
| 73 |
} |
} |
| 74 |
-(IBAction)createNewMessage:(id)sender{ |
-(IBAction)createNewMessage:(id)sender{ |
| 75 |
ComposeController *controller = [[ComposeController alloc] init]; |
AddressBookController *anAddressBookController = [self createAddressBookController]; |
| 76 |
[controller setAddressBookController:[self addressBookController]]; |
ComposeController *aComposeController = [[ComposeController alloc] init]; |
| 77 |
[[self addressBookController] setComposeController:controller]; |
|
| 78 |
[controller createNewMessageWithHeader:nil contents:nil]; |
[aComposeController setAddressBookController:anAddressBookController]; |
| 79 |
[composeControllers addObject:controller]; |
[anAddressBookController setWindowController:aComposeController]; |
| 80 |
[controller release]; |
[aComposeController createNewMessageWithHeader:nil contents:nil]; |
| 81 |
|
[composeControllers addObject:aComposeController]; |
| 82 |
|
[aComposeController release]; |
| 83 |
|
|
| 84 |
} |
} |
| 85 |
-(IBAction)showPreference:(id)sender{ |
-(IBAction)showPreference:(id)sender{ |
| 112 |
NSAttributedString *headerString; |
NSAttributedString *headerString; |
| 113 |
NSAttributedString *contentsString; |
NSAttributedString *contentsString; |
| 114 |
NSTextStorage *textStorage; |
NSTextStorage *textStorage; |
| 115 |
|
NSTextStorage *attachmentTextStorage; |
| 116 |
|
NSWorkspace *workspace; |
| 117 |
|
NSImage *icon; |
| 118 |
|
NSTextAttachment *textAttachment; |
| 119 |
|
|
| 120 |
|
workspace = [NSWorkspace sharedWorkspace]; |
| 121 |
|
icon = [workspace iconForFile: @"/Volumes/User/taninaka/20021226.lzh"]; |
| 122 |
|
|
| 123 |
|
|
| 124 |
|
// ****** dummy code start ****// |
| 125 |
|
textAttachment = [[NSTextAttachment alloc] init]; |
| 126 |
|
[textAttachment setAttachmentCell:[[IconedTextAttachmentCell alloc] init]]; |
| 127 |
|
[[textAttachment attachmentCell] setImage:icon]; |
| 128 |
|
[[textAttachment attachmentCell] setTitle:@"text.txt"]; |
| 129 |
|
// ****** dummy code end ****// |
| 130 |
|
|
| 131 |
ds = [aTableView dataSource]; |
ds = [aTableView dataSource]; |
| 132 |
selectedMailBox = [ds mailBox]; |
selectedMailBox = [ds mailBox]; |
| 139 |
[textStorage appendAttributedString:headerString]; |
[textStorage appendAttributedString:headerString]; |
| 140 |
[textStorage appendAttributedString:contentsString]; |
[textStorage appendAttributedString:contentsString]; |
| 141 |
[textStorage endEditing]; |
[textStorage endEditing]; |
| 142 |
|
|
| 143 |
|
attachmentTextStorage = [attachmentView textStorage]; |
| 144 |
|
[attachmentTextStorage beginEditing]; |
| 145 |
|
[attachmentTextStorage setAttributedString: |
| 146 |
|
[[NSAttributedString alloc] initWithString:@"hogehoge"]]; |
| 147 |
|
[attachmentTextStorage appendAttributedString: |
| 148 |
|
[NSAttributedString attributedStringWithAttachment:textAttachment]]; |
| 149 |
|
[attachmentTextStorage endEditing]; |
| 150 |
|
|
| 151 |
[mail setIsUnread:NO]; |
[mail setIsUnread:NO]; |
| 152 |
[folderTree reloadData]; |
[folderTree reloadData]; |
| 153 |
|
[drawer setContentSize:[drawer minContentSize]]; |
| 154 |
|
[drawer toggle:self]; |
| 155 |
|
|
| 156 |
return YES; |
return YES; |
| 157 |
} |
} |
| 158 |
//-(IBAction)showAddressBook{ |
-(IBAction)showAddressBook:(id)sender{ |
| 159 |
// [addressBookDrawer toggle:self]; |
[myAddressBookController showAddressBookWindow]; |
|
//} |
|
|
-(AddressBookController *)addressBookController{ |
|
|
if(addressbookController == nil){ |
|
|
addressbookController |
|
|
= [[AddressBookController alloc] init]; |
|
|
} |
|
|
[addressbookController window]; |
|
|
return addressbookController; |
|
| 160 |
} |
} |
| 161 |
|
-(AddressBookController *)createAddressBookController{ |
| 162 |
|
AddressBookController *anAddressbookController; |
| 163 |
|
anAddressbookController |
| 164 |
|
= [[[AddressBookController alloc] init] autorelease]; |
| 165 |
|
[anAddressbookController window]; |
| 166 |
|
return anAddressbookController; |
| 167 |
|
} |
| 168 |
|
|
| 169 |
@end |
@end |