| 1 |
#import "MainController.h" |
| 2 |
#import "DummyOutlineDataSource.h" |
| 3 |
#import "MainToolbarSource.h" |
| 4 |
#import "IconedCell.h" |
| 5 |
#import "ComposeToolbarSource.h" |
| 6 |
#import "PreferenceToolbarSource.h" |
| 7 |
|
| 8 |
@implementation MainController |
| 9 |
-(void)awakeFromNib{ |
| 10 |
DummyOutlineDataSource *ds; |
| 11 |
NSToolbar *toolbar; |
| 12 |
MainToolbarSource *mainToolbarSource; |
| 13 |
ComposeToolbarSource *composeToolbarSource; |
| 14 |
PreferenceToolbarSource *preferenceToolbarSource; |
| 15 |
|
| 16 |
[preferenceWindow setContentSize:[generalPref bounds].size]; |
| 17 |
[[preferenceWindow contentView] addSubview:generalPref]; |
| 18 |
|
| 19 |
ds = [[DummyOutlineDataSource alloc] init]; |
| 20 |
[folderTree setDataSource:ds]; |
| 21 |
|
| 22 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"myToolBar"]; |
| 23 |
mainToolbarSource = [[MainToolbarSource alloc] initWithController:self]; |
| 24 |
[toolbar setDelegate:mainToolbarSource]; |
| 25 |
[window setToolbar:toolbar]; |
| 26 |
[toolbar release]; |
| 27 |
|
| 28 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"componentToolBar"]; |
| 29 |
composeToolbarSource = [[ComposeToolbarSource alloc] initWithController:self]; |
| 30 |
[toolbar setDelegate:composeToolbarSource]; |
| 31 |
[composeWindow setToolbar:toolbar]; |
| 32 |
[toolbar release]; |
| 33 |
|
| 34 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"preferenceToolBar"]; |
| 35 |
preferenceToolbarSource = [[PreferenceToolbarSource alloc] initWithController:self]; |
| 36 |
[toolbar setDelegate:preferenceToolbarSource]; |
| 37 |
[preferenceWindow setToolbar:toolbar]; |
| 38 |
[toolbar release]; |
| 39 |
|
| 40 |
} |
| 41 |
- (void)applicationDidFinishLaunching:(NSNotification*)notif |
| 42 |
{ |
| 43 |
NSTableColumn* tableColumn; |
| 44 |
IconedCell* iconedCell; |
| 45 |
// �t�H���_�c���[���A�A�C�R��+�������\���������������ACell�����X���s���B |
| 46 |
tableColumn = [folderTree tableColumnWithIdentifier:@"folderview"]; |
| 47 |
iconedCell = [[[IconedCell alloc] init] autorelease]; |
| 48 |
[tableColumn setDataCell:iconedCell]; |
| 49 |
} |
| 50 |
-(IBAction)createNewMessage:(id)sender{ |
| 51 |
[composeWindow makeKeyAndOrderFront:nil]; |
| 52 |
} |
| 53 |
-(IBAction)findMessage:(id)sender{ |
| 54 |
[searchWindow makeKeyAndOrderFront:nil]; |
| 55 |
} |
| 56 |
-(IBAction)showPreference:(id)sender{ |
| 57 |
[preferenceWindow makeKeyAndOrderFront:nil]; |
| 58 |
} |
| 59 |
-(IBAction)selectPreferenceTab:(id)sender{ |
| 60 |
NSString *identifier = [sender itemIdentifier]; |
| 61 |
if([identifier isEqual:@"general_tab"]){ |
| 62 |
[self changePreferenceView:generalPref]; |
| 63 |
}else{ |
| 64 |
[self changePreferenceView:accountPref]; |
| 65 |
} |
| 66 |
|
| 67 |
} |
| 68 |
-(IBAction)changePreferenceView:(NSView *)newView{ |
| 69 |
|
| 70 |
NSRect oldContentRect; // �����O���R���e���c�r���[��Rect |
| 71 |
NSRect oldWindowRect; // �����O��Window��Rect |
| 72 |
NSRect newContentRect; // ���������R���e���c�r���[��Rect |
| 73 |
NSRect newWindowRect; // ��������Window�[��Rect |
| 74 |
float toolbarHeight; // �c�[���o�[������ |
| 75 |
|
| 76 |
NSView *contentsView; // Window���R���e���c�r���[ |
| 77 |
|
| 78 |
oldWindowRect = [preferenceWindow frame]; |
| 79 |
oldContentRect = [[preferenceWindow contentView] bounds]; |
| 80 |
|
| 81 |
toolbarHeight = NSHeight(oldWindowRect) - NSHeight(oldContentRect); |
| 82 |
|
| 83 |
newContentRect = [newView bounds]; |
| 84 |
|
| 85 |
// ���T�C�Y����Window��Rect���v�Z |
| 86 |
newWindowRect.origin.x |
| 87 |
= oldWindowRect.origin.x; |
| 88 |
newWindowRect.origin.y |
| 89 |
= oldWindowRect.origin.y + (NSHeight(oldContentRect) - NSHeight(newContentRect)); |
| 90 |
newWindowRect.size.width |
| 91 |
= newContentRect.size.width; |
| 92 |
newWindowRect.size.height |
| 93 |
= toolbarHeight + newContentRect.size.height; |
| 94 |
|
| 95 |
contentsView = [preferenceWindow contentView]; |
| 96 |
[contentsView replaceSubview:[[contentsView subviews] objectAtIndex:0] with:newView]; |
| 97 |
[preferenceWindow setFrame:newWindowRect display:YES animate:YES]; |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
@end |