Develop and Download Open Source Software

Browse CVS Repository

Annotation of /undmail/guiproto/MainController.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.18 - (hide annotations) (download)
Sat Feb 15 05:21:40 2003 UTC (21 years, 2 months ago) by footashida
Branch: MAIN
Changes since 1.17: +1 -2 lines
*** empty log message ***

1 footashida 1.1 #import "MainController.h"
2 footashida 1.12 #import "MailBoxOutlineDataSource.h"
3 footashida 1.2 #import "MainToolbarSource.h"
4 footashida 1.1 #import "IconedCell.h"
5 footashida 1.2 #import "ComposeToolbarSource.h"
6 footashida 1.12 #import "PreferenceController.h"
7     #import "DUMMailBoxManager.h"
8     #import "MailBoxTableDataSource.h"
9 footashida 1.13 #import "DUMMail.h"
10     #import "DUMMailBox.h"
11 footashida 1.14 #import "AddressBookController.h"
12 footashida 1.17 #import "ComposeController.h"
13     #import "TextFormatter.h"
14     #import "LineTextFormatter.h"
15     #import "MailTextFormatManager.h"
16 footashida 1.16
17 footashida 1.1 @implementation MainController
18 footashida 1.13 -(void)setupToolbar{
19 footashida 1.1 NSToolbar *toolbar;
20 footashida 1.2 MainToolbarSource *mainToolbarSource;
21 footashida 1.5 toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"];
22 footashida 1.2 mainToolbarSource = [[MainToolbarSource alloc] initWithController:self];
23     [toolbar setDelegate:mainToolbarSource];
24 footashida 1.1 [window setToolbar:toolbar];
25     [toolbar release];
26    
27 footashida 1.13 }
28     -(void)awakeFromNib{
29     MailBoxOutlineDataSource *ds;
30 footashida 1.18
31 footashida 1.13 [window center];
32     mailBoxManager = [[DUMMailBoxManager alloc] init];
33     ds = [[MailBoxOutlineDataSource alloc]
34     initWithMailBoxManager:mailBoxManager];
35     [folderTree setDataSource:ds];
36     [self setupToolbar];
37 footashida 1.17 // addressBookView = [[[self addressBookController] addressBookView] retain];
38     // [addressBookDrawer setContentView:addressBookView];
39     composeControllers = [[NSMutableArray alloc] init];
40 footashida 1.1
41 footashida 1.17 [[mailContents textStorage] setDelegate:self];
42     mailTextFormatManager = [[MailTextFormatManager alloc] init];
43     [mailTextFormatManager addHeaderTextFormatter:
44     [[TextFormatter alloc] initWithName:@"default"
45     pattern:@""
46     foregroundColor:[NSColor blackColor]
47     backgroundColor:[NSColor whiteColor]
48     font:[NSFont fontWithName:@"HiraKakuPro-W3" size:13.0]]];
49     [mailTextFormatManager addContentsTextFormatter:
50     [[TextFormatter alloc] initWithName:@"default"
51     pattern:@""
52     foregroundColor:[NSColor blackColor]
53     backgroundColor:[NSColor whiteColor]
54     font:[NSFont fontWithName:@"HiraKakuPro-W3" size:12.0]]];
55    
56     [mailTextFormatManager addContentsTextFormatter:
57     [[LineTextFormatter alloc] initWithName:@"inyo"
58     pattern:@">"
59     foregroundColor:[NSColor colorWithCalibratedRed:0.0
60     green:0.8
61     blue:0.48
62     alpha:1.0]
63     backgroundColor:[NSColor whiteColor]
64     font:[NSFont fontWithName:@"HiraKakuPro-W3" size:12.0]]];
65    
66 footashida 1.1 }
67 footashida 1.15 -(void)dealloc{
68     [window release];
69     [searchWindow release];
70     [mailList release];
71     [folderTree release];
72     [mailContents release];
73     [mailBoxManager release];
74     [prefController release];
75     [addressbookController release];
76 footashida 1.17 [mailTextFormatManager release];
77 footashida 1.15 [super dealloc];
78     }
79 footashida 1.17 -(BOOL)windowShouldClose:(id)sender{
80     NSLog(@"window close!");
81     [composeControllers removeObject:[sender windowController]];
82     return YES;
83     }
84 footashida 1.1 - (void)applicationDidFinishLaunching:(NSNotification*)notif
85     {
86     NSTableColumn* tableColumn;
87     IconedCell* iconedCell;
88     // �t�H���_�c���[���A�A�C�R��+�������\���������������ACell�����X���s���B
89     tableColumn = [folderTree tableColumnWithIdentifier:@"folderview"];
90     iconedCell = [[[IconedCell alloc] init] autorelease];
91     [tableColumn setDataCell:iconedCell];
92     }
93     -(IBAction)createNewMessage:(id)sender{
94 footashida 1.17 ComposeController *controller = [[ComposeController alloc] init];
95     [controller setAddressBookController:[self addressBookController]];
96     [[self addressBookController] setComposeController:controller];
97     [controller createNewMessageWithHeader:nil contents:nil];
98     [composeControllers addObject:controller];
99     [controller release];
100    
101 footashida 1.1 }
102 footashida 1.2 -(IBAction)showPreference:(id)sender{
103 footashida 1.12 if(prefController == nil){
104     prefController = [[PreferenceController alloc] init];
105 footashida 1.3 }
106 footashida 1.12 [prefController showWindow:self];
107 footashida 1.1 }
108 footashida 1.9 -(IBAction)createRule:(id)sender{
109     [self showPreference:self];
110 footashida 1.12 [prefController selectPreferenceTabWithName:@"rule_tab"];
111     }
112     - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item{
113     MailBoxTableDataSource *ds;
114    
115     if([mailList dataSource] == nil){
116     ds = [[MailBoxTableDataSource alloc] initWithMailBox:item];
117     [mailList setDataSource:ds];
118     }else{
119     ds = [mailList dataSource];
120     [ds changeMailBox:item];
121     }
122     [mailList reloadData];
123 footashida 1.13 return YES;
124     }
125     - (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex{
126     MailBoxTableDataSource *ds;
127     DUMMailBox *selectedMailBox;
128     DUMMail *mail;
129 footashida 1.17 NSAttributedString *headerString;
130     NSAttributedString *contentsString;
131     NSTextStorage *textStorage;
132 footashida 1.13
133     ds = [aTableView dataSource];
134     selectedMailBox = [ds mailBox];
135     mail = [selectedMailBox mailAtIndex:rowIndex];
136 footashida 1.17 headerString = [mailTextFormatManager formatHeader:[mail headerText]];
137     contentsString = [mailTextFormatManager formatContents:[mail content]];
138     textStorage = [mailContents textStorage];
139     [textStorage beginEditing];
140     [textStorage deleteCharactersInRange:NSMakeRange(0, [textStorage length])];
141     [textStorage appendAttributedString:headerString];
142     [textStorage appendAttributedString:contentsString];
143     [textStorage endEditing];
144 footashida 1.15 [mail setIsUnread:NO];
145     [folderTree reloadData];
146 footashida 1.12 return YES;
147 footashida 1.14 }
148 footashida 1.17 //-(IBAction)showAddressBook{
149     // [addressBookDrawer toggle:self];
150     //}
151 footashida 1.16 -(AddressBookController *)addressBookController{
152 footashida 1.14 if(addressbookController == nil){
153     addressbookController
154     = [[AddressBookController alloc] init];
155     }
156 footashida 1.16 [addressbookController window];
157     return addressbookController;
158 footashida 1.9 }
159 footashida 1.17 @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26