| 1 |
#import "MainController.h" |
#import "MainController.h" |
| 2 |
#import "DummyOutlineDataSource.h" |
#import "MailBoxOutlineDataSource.h" |
| 3 |
#import "MainToolbarSource.h" |
#import "MainToolbarSource.h" |
| 4 |
#import "IconedCell.h" |
#import "IconedCell.h" |
| 5 |
#import "ComposeToolbarSource.h" |
#import "ComposeToolbarSource.h" |
| 6 |
#import "PreferenceToolbarSource.h" |
#import "PreferenceToolbarSource.h" |
| 7 |
|
#import "PreferenceController.h" |
| 8 |
|
#import "DUMMailBoxManager.h" |
| 9 |
|
#import "MailBoxTableDataSource.h" |
| 10 |
@implementation MainController |
@implementation MainController |
| 11 |
-(void)awakeFromNib{ |
-(void)awakeFromNib{ |
| 12 |
DummyOutlineDataSource *ds; |
MailBoxOutlineDataSource *ds; |
| 13 |
NSToolbar *toolbar; |
NSToolbar *toolbar; |
| 14 |
MainToolbarSource *mainToolbarSource; |
MainToolbarSource *mainToolbarSource; |
| 15 |
ComposeToolbarSource *composeToolbarSource; |
ComposeToolbarSource *composeToolbarSource; |
|
PreferenceToolbarSource *preferenceToolbarSource; |
|
| 16 |
NSButtonCell *mailCheckButtonCell; |
NSButtonCell *mailCheckButtonCell; |
| 17 |
NSButtonCell *mailDeleteButtonCell; |
NSButtonCell *mailDeleteButtonCell; |
| 18 |
|
|
| 19 |
[window center]; |
[window center]; |
| 20 |
|
|
| 21 |
[preferenceWindow setContentSize:[generalPref bounds].size]; |
mailBoxManager = [[DUMMailBoxManager alloc] init]; |
| 22 |
[[preferenceWindow contentView] addSubview:generalPref]; |
ds = [[MailBoxOutlineDataSource alloc] |
| 23 |
[preferenceWindow center]; |
initWithMailBoxManager:mailBoxManager]; |
|
|
|
|
ds = [[DummyOutlineDataSource alloc] init]; |
|
| 24 |
[folderTree setDataSource:ds]; |
[folderTree setDataSource:ds]; |
| 25 |
|
|
| 26 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"]; |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"]; |
| 35 |
[composeWindow setToolbar:toolbar]; |
[composeWindow setToolbar:toolbar]; |
| 36 |
[toolbar release]; |
[toolbar release]; |
| 37 |
|
|
|
toolbar = [[NSToolbar alloc] initWithIdentifier:@"PreferenceToolBar"]; |
|
|
preferenceToolbarSource = [[PreferenceToolbarSource alloc] initWithController:self]; |
|
|
[toolbar setDelegate:preferenceToolbarSource]; |
|
|
[preferenceWindow setToolbar:toolbar]; |
|
|
[toolbar release]; |
|
|
|
|
| 38 |
mailCheckButtonCell = [[NSButtonCell alloc] init]; |
mailCheckButtonCell = [[NSButtonCell alloc] init]; |
| 39 |
mailDeleteButtonCell = [[NSButtonCell alloc] init]; |
mailDeleteButtonCell = [[NSButtonCell alloc] init]; |
| 40 |
[mailCheckButtonCell setButtonType:NSSwitchButton]; |
[mailCheckButtonCell setButtonType:NSSwitchButton]; |
| 45 |
|
|
| 46 |
[[mailCheckTable tableColumnWithIdentifier:@"MailCheckFlag"] setDataCell:mailCheckButtonCell]; |
[[mailCheckTable tableColumnWithIdentifier:@"MailCheckFlag"] setDataCell:mailCheckButtonCell]; |
| 47 |
[[mailCheckTable tableColumnWithIdentifier:@"MailDeleteFlag"] setDataCell:mailDeleteButtonCell]; |
[[mailCheckTable tableColumnWithIdentifier:@"MailDeleteFlag"] setDataCell:mailDeleteButtonCell]; |
|
|
|
|
|
|
| 48 |
} |
} |
| 49 |
- (void)applicationDidFinishLaunching:(NSNotification*)notif |
- (void)applicationDidFinishLaunching:(NSNotification*)notif |
| 50 |
{ |
{ |
| 59 |
[composeWindow makeKeyAndOrderFront:nil]; |
[composeWindow makeKeyAndOrderFront:nil]; |
| 60 |
} |
} |
| 61 |
-(IBAction)showPreference:(id)sender{ |
-(IBAction)showPreference:(id)sender{ |
| 62 |
[preferenceWindow makeKeyAndOrderFront:nil]; |
if(prefController == nil){ |
| 63 |
} |
prefController = [[PreferenceController alloc] init]; |
|
-(IBAction)selectPreferenceTab:(id)sender{ |
|
|
NSString *identifier = [sender itemIdentifier]; |
|
|
if([identifier isEqual:@"general_tab"]){ |
|
|
[self changePreferenceView:generalPref]; |
|
|
}else if([identifier isEqual:@"view_tab"]){ |
|
|
[self changePreferenceView:viewPref]; |
|
|
}else if([identifier isEqual:@"account_tab"]){ |
|
|
[self changePreferenceView:accountPref]; |
|
|
}else if([identifier isEqual:@"template_tab"]){ |
|
|
[self changePreferenceView:templatePref]; |
|
|
}else if([identifier isEqual:@"rule_tab"]){ |
|
|
[self changePreferenceView:rulePref]; |
|
|
}else{ |
|
|
// ありえないはず・・・ |
|
| 64 |
} |
} |
| 65 |
|
[prefController showWindow:self]; |
|
} |
|
|
-(IBAction)changePreferenceView:(NSView *)newView{ |
|
|
|
|
|
NSRect oldContentRect; // 切替前のコンテンツビューのRect |
|
|
NSRect oldWindowRect; // 切替前のWindowのRect |
|
|
NSRect newContentRect; // 切替後のコンテンツビューのRect |
|
|
NSRect newWindowRect; // 切替後のWindowーのRect |
|
|
float toolbarHeight; // ツールバーの高さ |
|
|
|
|
|
NSView *contentsView; // Windowのコンテンツビュー |
|
|
NSView *oldView; |
|
|
NSView *dumView; |
|
|
|
|
|
oldWindowRect = [preferenceWindow frame]; |
|
|
oldContentRect = [[preferenceWindow contentView] bounds]; |
|
|
|
|
|
toolbarHeight = NSHeight(oldWindowRect) - NSHeight(oldContentRect); |
|
|
|
|
|
newContentRect = [newView bounds]; |
|
|
|
|
|
// リサイズ後のWindowのRectを計算 |
|
|
newWindowRect.origin.x |
|
|
= oldWindowRect.origin.x; |
|
|
newWindowRect.origin.y |
|
|
= oldWindowRect.origin.y + (NSHeight(oldContentRect) - NSHeight(newContentRect)); |
|
|
newWindowRect.size.width |
|
|
= newContentRect.size.width; |
|
|
newWindowRect.size.height |
|
|
= toolbarHeight + newContentRect.size.height; |
|
|
|
|
|
contentsView = [preferenceWindow contentView]; |
|
|
oldView = [[contentsView subviews] objectAtIndex:0]; |
|
|
dumView = [[NSView alloc] init]; |
|
|
[contentsView replaceSubview:oldView with:dumView]; |
|
|
[preferenceWindow setFrame:newWindowRect display:YES animate:YES]; |
|
|
[contentsView replaceSubview:dumView with:newView]; |
|
|
[dumView release]; |
|
|
|
|
| 66 |
} |
} |
| 67 |
-(IBAction)createRule:(id)sender{ |
-(IBAction)createRule:(id)sender{ |
| 68 |
[self showPreference:self]; |
[self showPreference:self]; |
| 69 |
[self changePreferenceView:rulePref]; |
[prefController selectPreferenceTabWithName:@"rule_tab"]; |
| 70 |
|
} |
| 71 |
|
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item{ |
| 72 |
|
MailBoxTableDataSource *ds; |
| 73 |
|
|
| 74 |
|
if([mailList dataSource] == nil){ |
| 75 |
|
ds = [[MailBoxTableDataSource alloc] initWithMailBox:item]; |
| 76 |
|
[mailList setDataSource:ds]; |
| 77 |
|
}else{ |
| 78 |
|
ds = [mailList dataSource]; |
| 79 |
|
[ds changeMailBox:item]; |
| 80 |
|
} |
| 81 |
|
[mailList reloadData]; |
| 82 |
|
return YES; |
| 83 |
} |
} |
| 84 |
@end |
@end |