| 9 |
#import "DUMMail.h" |
#import "DUMMail.h" |
| 10 |
#import "DUMMailBox.h" |
#import "DUMMailBox.h" |
| 11 |
#import "AddressBookController.h" |
#import "AddressBookController.h" |
| 12 |
|
#import "ComposeController.h" |
| 13 |
|
#import "TextFormatter.h" |
| 14 |
|
#import "LineTextFormatter.h" |
| 15 |
|
#import "MailTextFormatManager.h" |
| 16 |
|
|
| 17 |
@implementation MainController |
@implementation MainController |
| 18 |
-(void)setupToolbar{ |
-(void)setupToolbar{ |
| 19 |
NSToolbar *toolbar; |
NSToolbar *toolbar; |
| 20 |
MainToolbarSource *mainToolbarSource; |
MainToolbarSource *mainToolbarSource; |
|
ComposeToolbarSource *composeToolbarSource; |
|
| 21 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"]; |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"]; |
| 22 |
mainToolbarSource = [[MainToolbarSource alloc] initWithController:self]; |
mainToolbarSource = [[MainToolbarSource alloc] initWithController:self]; |
| 23 |
[toolbar setDelegate:mainToolbarSource]; |
[toolbar setDelegate:mainToolbarSource]; |
| 24 |
[window setToolbar:toolbar]; |
[window setToolbar:toolbar]; |
| 25 |
[toolbar release]; |
[toolbar release]; |
| 26 |
|
|
|
toolbar = [[NSToolbar alloc] initWithIdentifier:@"ComposeToolBar"]; |
|
|
composeToolbarSource = [[ComposeToolbarSource alloc] initWithController:self]; |
|
|
[toolbar setDelegate:composeToolbarSource]; |
|
|
[composeWindow setToolbar:toolbar]; |
|
|
[toolbar release]; |
|
| 27 |
} |
} |
| 28 |
-(void)awakeFromNib{ |
-(void)awakeFromNib{ |
| 29 |
MailBoxOutlineDataSource *ds; |
MailBoxOutlineDataSource *ds; |
| 34 |
ds = [[MailBoxOutlineDataSource alloc] |
ds = [[MailBoxOutlineDataSource alloc] |
| 35 |
initWithMailBoxManager:mailBoxManager]; |
initWithMailBoxManager:mailBoxManager]; |
| 36 |
[folderTree setDataSource:ds]; |
[folderTree setDataSource:ds]; |
|
|
|
| 37 |
[self setupToolbar]; |
[self setupToolbar]; |
| 38 |
|
// addressBookView = [[[self addressBookController] addressBookView] retain]; |
| 39 |
|
// [addressBookDrawer setContentView:addressBookView]; |
| 40 |
|
composeControllers = [[NSMutableArray alloc] init]; |
| 41 |
|
|
| 42 |
addressBookView = [[[self addressBookController] addressBookView] retain]; |
[[mailContents textStorage] setDelegate:self]; |
| 43 |
[addressBookDrawer setContentView:addressBookView]; |
mailTextFormatManager = [[MailTextFormatManager alloc] init]; |
| 44 |
|
[mailTextFormatManager addHeaderTextFormatter: |
| 45 |
|
[[TextFormatter alloc] initWithName:@"default" |
| 46 |
|
pattern:@"" |
| 47 |
|
foregroundColor:[NSColor blackColor] |
| 48 |
|
backgroundColor:[NSColor whiteColor] |
| 49 |
|
font:[NSFont fontWithName:@"HiraKakuPro-W3" size:13.0]]]; |
| 50 |
|
[mailTextFormatManager addContentsTextFormatter: |
| 51 |
|
[[TextFormatter alloc] initWithName:@"default" |
| 52 |
|
pattern:@"" |
| 53 |
|
foregroundColor:[NSColor blackColor] |
| 54 |
|
backgroundColor:[NSColor whiteColor] |
| 55 |
|
font:[NSFont fontWithName:@"HiraKakuPro-W3" size:12.0]]]; |
| 56 |
|
|
| 57 |
|
[mailTextFormatManager addContentsTextFormatter: |
| 58 |
|
[[LineTextFormatter alloc] initWithName:@"inyo" |
| 59 |
|
pattern:@">" |
| 60 |
|
foregroundColor:[NSColor colorWithCalibratedRed:0.0 |
| 61 |
|
green:0.8 |
| 62 |
|
blue:0.48 |
| 63 |
|
alpha:1.0] |
| 64 |
|
backgroundColor:[NSColor whiteColor] |
| 65 |
|
font:[NSFont fontWithName:@"HiraKakuPro-W3" size:12.0]]]; |
| 66 |
|
|
| 67 |
} |
} |
| 68 |
-(void)dealloc{ |
-(void)dealloc{ |
| 69 |
[window release]; |
[window release]; |
|
[composeWindow release]; |
|
| 70 |
[searchWindow release]; |
[searchWindow release]; |
| 71 |
[mailList release]; |
[mailList release]; |
| 72 |
[folderTree release]; |
[folderTree release]; |
| 74 |
[mailBoxManager release]; |
[mailBoxManager release]; |
| 75 |
[prefController release]; |
[prefController release]; |
| 76 |
[addressbookController release]; |
[addressbookController release]; |
| 77 |
|
[mailTextFormatManager release]; |
| 78 |
[super dealloc]; |
[super dealloc]; |
| 79 |
} |
} |
| 80 |
|
-(BOOL)windowShouldClose:(id)sender{ |
| 81 |
|
NSLog(@"window close!"); |
| 82 |
|
[composeControllers removeObject:[sender windowController]]; |
| 83 |
|
return YES; |
| 84 |
|
} |
| 85 |
- (void)applicationDidFinishLaunching:(NSNotification*)notif |
- (void)applicationDidFinishLaunching:(NSNotification*)notif |
| 86 |
{ |
{ |
| 87 |
NSTableColumn* tableColumn; |
NSTableColumn* tableColumn; |
| 92 |
[tableColumn setDataCell:iconedCell]; |
[tableColumn setDataCell:iconedCell]; |
| 93 |
} |
} |
| 94 |
-(IBAction)createNewMessage:(id)sender{ |
-(IBAction)createNewMessage:(id)sender{ |
| 95 |
[composeWindow makeKeyAndOrderFront:nil]; |
ComposeController *controller = [[ComposeController alloc] init]; |
| 96 |
|
[controller setAddressBookController:[self addressBookController]]; |
| 97 |
|
[[self addressBookController] setComposeController:controller]; |
| 98 |
|
[controller createNewMessageWithHeader:nil contents:nil]; |
| 99 |
|
[composeControllers addObject:controller]; |
| 100 |
|
[controller release]; |
| 101 |
|
|
| 102 |
} |
} |
| 103 |
-(IBAction)showPreference:(id)sender{ |
-(IBAction)showPreference:(id)sender{ |
| 104 |
if(prefController == nil){ |
if(prefController == nil){ |
| 127 |
MailBoxTableDataSource *ds; |
MailBoxTableDataSource *ds; |
| 128 |
DUMMailBox *selectedMailBox; |
DUMMailBox *selectedMailBox; |
| 129 |
DUMMail *mail; |
DUMMail *mail; |
| 130 |
NSString *text; |
NSAttributedString *headerString; |
| 131 |
|
NSAttributedString *contentsString; |
| 132 |
|
NSTextStorage *textStorage; |
| 133 |
|
|
| 134 |
ds = [aTableView dataSource]; |
ds = [aTableView dataSource]; |
| 135 |
selectedMailBox = [ds mailBox]; |
selectedMailBox = [ds mailBox]; |
| 136 |
mail = [selectedMailBox mailAtIndex:rowIndex]; |
mail = [selectedMailBox mailAtIndex:rowIndex]; |
| 137 |
text = [NSString stringWithFormat:@"%@\r\n\r\n%@", |
headerString = [mailTextFormatManager formatHeader:[mail headerText]]; |
| 138 |
[mail headerText], |
contentsString = [mailTextFormatManager formatContents:[mail content]]; |
| 139 |
[mail content]]; |
textStorage = [mailContents textStorage]; |
| 140 |
[mailContents |
[textStorage beginEditing]; |
| 141 |
replaceCharactersInRange: |
[textStorage deleteCharactersInRange:NSMakeRange(0, [textStorage length])]; |
| 142 |
NSMakeRange(0, [[mailContents string] length]) |
[textStorage appendAttributedString:headerString]; |
| 143 |
withString:text]; |
[textStorage appendAttributedString:contentsString]; |
| 144 |
|
[textStorage endEditing]; |
| 145 |
[mail setIsUnread:NO]; |
[mail setIsUnread:NO]; |
| 146 |
[folderTree reloadData]; |
[folderTree reloadData]; |
| 147 |
return YES; |
return YES; |
| 148 |
} |
} |
| 149 |
-(IBAction)showAddressBook{ |
//-(IBAction)showAddressBook{ |
| 150 |
[addressBookDrawer toggle:self]; |
// [addressBookDrawer toggle:self]; |
| 151 |
// if(addressbookController == nil){ |
//} |
|
// addressbookController |
|
|
// = [[AddressBookController alloc] init]; |
|
|
// } |
|
|
// [addressbookController showWindow:self]; |
|
|
} |
|
| 152 |
-(AddressBookController *)addressBookController{ |
-(AddressBookController *)addressBookController{ |
| 153 |
if(addressbookController == nil){ |
if(addressbookController == nil){ |
| 154 |
addressbookController |
addressbookController |
| 157 |
[addressbookController window]; |
[addressbookController window]; |
| 158 |
return addressbookController; |
return addressbookController; |
| 159 |
} |
} |
| 160 |
@end |
@end |