| 1 |
#import "PreferenceController.h" |
| 2 |
#import "PreferenceToolbarSource.h" |
| 3 |
|
| 4 |
@implementation PreferenceController |
| 5 |
-(void)setupToolbar:(NSWindow *)window{ |
| 6 |
NSToolbar *toolbar; |
| 7 |
PreferenceToolbarSource *preferenceToolbarSource; |
| 8 |
toolbar = [[NSToolbar alloc] initWithIdentifier:@"PreferenceToolBar"]; |
| 9 |
preferenceToolbarSource = [[PreferenceToolbarSource alloc] initWithController:self]; |
| 10 |
[toolbar setDelegate:preferenceToolbarSource]; |
| 11 |
[window setToolbar:toolbar]; |
| 12 |
[toolbar release]; |
| 13 |
} |
| 14 |
|
| 15 |
-(id)init{ |
| 16 |
self = [super initWithWindowNibName:@"Preference"]; |
| 17 |
return self; |
| 18 |
} |
| 19 |
-(void)dealloc{ |
| 20 |
[preferencePanel release]; |
| 21 |
[accountPref release]; |
| 22 |
[generalPref release]; |
| 23 |
[viewPref release]; |
| 24 |
[templatePref release]; |
| 25 |
[rulePref release]; |
| 26 |
[popServerTable release]; |
| 27 |
[smtpServerTable release]; |
| 28 |
[mailCheckTable release]; |
| 29 |
[super dealloc]; |
| 30 |
} |
| 31 |
-(void)windowDidLoad{ |
| 32 |
NSWindow *window; |
| 33 |
NSButtonCell *mailCheckButtonCell; |
| 34 |
NSButtonCell *mailDeleteButtonCell; |
| 35 |
|
| 36 |
window = [self window]; |
| 37 |
[window setContentSize:[generalPref bounds].size]; |
| 38 |
[[window contentView] addSubview:generalPref]; |
| 39 |
[window center]; |
| 40 |
[self setupToolbar:window]; |
| 41 |
|
| 42 |
mailCheckButtonCell = [[NSButtonCell alloc] init]; |
| 43 |
mailDeleteButtonCell = [[NSButtonCell alloc] init]; |
| 44 |
[mailCheckButtonCell setButtonType:NSSwitchButton]; |
| 45 |
[mailDeleteButtonCell setButtonType:NSSwitchButton]; |
| 46 |
[mailCheckButtonCell setTitle:@""]; |
| 47 |
[mailDeleteButtonCell setTitle:@""]; |
| 48 |
[[mailCheckTable tableColumnWithIdentifier:@"MailCheckFlag"] setDataCell:mailCheckButtonCell]; |
| 49 |
[[mailCheckTable tableColumnWithIdentifier:@"MailDeleteFlag"] setDataCell:mailDeleteButtonCell]; |
| 50 |
|
| 51 |
} |
| 52 |
-(IBAction)selectPreferenceTab:(id)sender{ |
| 53 |
[self selectPreferenceTabWithName:[sender itemIdentifier]]; |
| 54 |
} |
| 55 |
-(void)selectPreferenceTabWithName:(NSString *)identifier{ |
| 56 |
if([identifier isEqual:@"general_tab"]){ |
| 57 |
[self changePreferenceView:generalPref]; |
| 58 |
}else if([identifier isEqual:@"view_tab"]){ |
| 59 |
[self changePreferenceView:viewPref]; |
| 60 |
}else if([identifier isEqual:@"account_tab"]){ |
| 61 |
[self changePreferenceView:accountPref]; |
| 62 |
}else if([identifier isEqual:@"template_tab"]){ |
| 63 |
[self changePreferenceView:templatePref]; |
| 64 |
}else if([identifier isEqual:@"rule_tab"]){ |
| 65 |
[self changePreferenceView:rulePref]; |
| 66 |
}else{ |
| 67 |
// ������������������������������ |
| 68 |
} |
| 69 |
} |
| 70 |
-(IBAction)changePreferenceView:(NSView *)newView{ |
| 71 |
|
| 72 |
NSRect oldContentRect; // ���������������������������������������Rect |
| 73 |
NSRect oldWindowRect; // ������������Window���Rect |
| 74 |
NSRect newContentRect; // ���������������������������������������Rect |
| 75 |
NSRect newWindowRect; // ������������Window������Rect |
| 76 |
float toolbarHeight; // ������������������������ |
| 77 |
|
| 78 |
NSView *contentsView; // Window��������������������������� |
| 79 |
NSView *oldView; |
| 80 |
NSView *dumView; |
| 81 |
|
| 82 |
NSWindow *preferenceWindow = [self window]; |
| 83 |
|
| 84 |
oldWindowRect = [preferenceWindow frame]; |
| 85 |
oldContentRect = [[preferenceWindow contentView] bounds]; |
| 86 |
|
| 87 |
toolbarHeight = NSHeight(oldWindowRect) - NSHeight(oldContentRect); |
| 88 |
|
| 89 |
newContentRect = [newView bounds]; |
| 90 |
|
| 91 |
// ������������������Window���Rect��������� |
| 92 |
newWindowRect.origin.x |
| 93 |
= oldWindowRect.origin.x; |
| 94 |
newWindowRect.origin.y |
| 95 |
= oldWindowRect.origin.y + (NSHeight(oldContentRect) - NSHeight(newContentRect)); |
| 96 |
newWindowRect.size.width |
| 97 |
= newContentRect.size.width; |
| 98 |
newWindowRect.size.height |
| 99 |
= toolbarHeight + newContentRect.size.height; |
| 100 |
|
| 101 |
contentsView = [preferenceWindow contentView]; |
| 102 |
oldView = [[contentsView subviews] objectAtIndex:0]; |
| 103 |
dumView = [[NSView alloc] init]; |
| 104 |
[contentsView replaceSubview:oldView with:dumView]; |
| 105 |
[preferenceWindow setFrame:newWindowRect display:YES animate:YES]; |
| 106 |
[contentsView replaceSubview:dumView with:newView]; |
| 107 |
[dumView release]; |
| 108 |
|
| 109 |
} |
| 110 |
|
| 111 |
@end |