Develop and Download Open Source Software

Browse CVS Repository

Contents of /undmail/guiproto/MainController.m

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


Revision 1.19 - (show annotations) (download)
Sun Feb 16 09:05:53 2003 UTC (21 years, 2 months ago) by footashida
Branch: MAIN
Changes since 1.18: +54 -44 lines
*** empty log message ***

1 #import "MainController.h"
2 #import "MailBoxOutlineDataSource.h"
3 #import "MainToolbarSource.h"
4 #import "IconedCell.h"
5 #import "ComposeToolbarSource.h"
6 #import "PreferenceController.h"
7 #import "DUMMailBoxManager.h"
8 #import "MailBoxTableDataSource.h"
9 #import "DUMMail.h"
10 #import "DUMMailBox.h"
11 #import "AddressBookController.h"
12 #import "ComposeController.h"
13 #import "TextFormatter.h"
14 #import "LineTextFormatter.h"
15 #import "MailTextFormatManager.h"
16 #import "IconedTextAttachmentCell.h"
17 @implementation MainController
18 -(void)setupToolbar{
19 NSToolbar *toolbar;
20 MainToolbarSource *mainToolbarSource;
21 toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"];
22 mainToolbarSource = [[MainToolbarSource alloc] initWithController:self];
23 [toolbar setDelegate:mainToolbarSource];
24 [window setToolbar:toolbar];
25 [toolbar release];
26
27 }
28 -(void)awakeFromNib{
29 MailBoxOutlineDataSource *ds;
30
31 [window center];
32 mailBoxManager = [[DUMMailBoxManager alloc] init];
33 ds = [[MailBoxOutlineDataSource alloc]
34 initWithMailBoxManager:mailBoxManager];
35 [folderTree setDataSource:ds];
36 [self setupToolbar];
37 composeControllers = [[NSMutableArray alloc] init];
38 myAddressBookController = [[self createAddressBookController] retain];
39 [myAddressBookController setWindowController:self];
40
41 [[mailContents textStorage] setDelegate:self];
42 mailTextFormatManager = [[MailTextFormatManager sharedMailTextFormatManager] retain];
43 }
44 -(void)dealloc{
45 [window release];
46 [searchWindow release];
47 [mailList release];
48 [folderTree release];
49 [mailContents release];
50 [mailBoxManager release];
51 [prefController release];
52 [myAddressBookController release];
53 [mailTextFormatManager release];
54 [super dealloc];
55 }
56 // ���C���E�B���h�E��NSWindowController�������O�������[�u
57 -(NSWindow *)window{
58 return window;
59 }
60 -(BOOL)windowShouldClose:(id)sender{
61 NSLog(@"window close!");
62 [composeControllers removeObject:[sender windowController]];
63 return YES;
64 }
65 - (void)applicationDidFinishLaunching:(NSNotification*)notif
66 {
67 NSTableColumn* tableColumn;
68 IconedCell* iconedCell;
69 // �t�H���_�c���[���A�A�C�R��+�������\���������������ACell�����X���s���B
70 tableColumn = [folderTree tableColumnWithIdentifier:@"folderview"];
71 iconedCell = [[[IconedCell alloc] init] autorelease];
72 [tableColumn setDataCell:iconedCell];
73 }
74 -(IBAction)createNewMessage:(id)sender{
75 AddressBookController *anAddressBookController = [self createAddressBookController];
76 ComposeController *aComposeController = [[ComposeController alloc] init];
77
78 [aComposeController setAddressBookController:anAddressBookController];
79 [anAddressBookController setWindowController:aComposeController];
80 [aComposeController createNewMessageWithHeader:nil contents:nil];
81 [composeControllers addObject:aComposeController];
82 [aComposeController release];
83
84 }
85 -(IBAction)showPreference:(id)sender{
86 if(prefController == nil){
87 prefController = [[PreferenceController alloc] init];
88 }
89 [prefController showWindow:self];
90 }
91 -(IBAction)createRule:(id)sender{
92 [self showPreference:self];
93 [prefController selectPreferenceTabWithName:@"rule_tab"];
94 }
95 - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item{
96 MailBoxTableDataSource *ds;
97
98 if([mailList dataSource] == nil){
99 ds = [[MailBoxTableDataSource alloc] initWithMailBox:item];
100 [mailList setDataSource:ds];
101 }else{
102 ds = [mailList dataSource];
103 [ds changeMailBox:item];
104 }
105 [mailList reloadData];
106 return YES;
107 }
108 - (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex{
109 MailBoxTableDataSource *ds;
110 DUMMailBox *selectedMailBox;
111 DUMMail *mail;
112 NSAttributedString *headerString;
113 NSAttributedString *contentsString;
114 NSTextStorage *textStorage;
115 NSTextStorage *attachmentTextStorage;
116 NSWorkspace *workspace;
117 NSImage *icon;
118 NSTextAttachment *textAttachment;
119
120 workspace = [NSWorkspace sharedWorkspace];
121 icon = [workspace iconForFile: @"/Volumes/User/taninaka/20021226.lzh"];
122
123
124 // ****** dummy code start ****//
125 textAttachment = [[NSTextAttachment alloc] init];
126 [textAttachment setAttachmentCell:[[IconedTextAttachmentCell alloc] init]];
127 [[textAttachment attachmentCell] setImage:icon];
128 [[textAttachment attachmentCell] setTitle:@"text.txt"];
129 // ****** dummy code end ****//
130
131 ds = [aTableView dataSource];
132 selectedMailBox = [ds mailBox];
133 mail = [selectedMailBox mailAtIndex:rowIndex];
134 headerString = [mailTextFormatManager formatHeader:[mail headerText]];
135 contentsString = [mailTextFormatManager formatContents:[mail content]];
136 textStorage = [mailContents textStorage];
137 [textStorage beginEditing];
138 [textStorage deleteCharactersInRange:NSMakeRange(0, [textStorage length])];
139 [textStorage appendAttributedString:headerString];
140 [textStorage appendAttributedString:contentsString];
141 [textStorage endEditing];
142
143 attachmentTextStorage = [attachmentView textStorage];
144 [attachmentTextStorage beginEditing];
145 [attachmentTextStorage setAttributedString:
146 [[NSAttributedString alloc] initWithString:@"hogehoge"]];
147 [attachmentTextStorage appendAttributedString:
148 [NSAttributedString attributedStringWithAttachment:textAttachment]];
149 [attachmentTextStorage endEditing];
150
151 [mail setIsUnread:NO];
152 [folderTree reloadData];
153 [drawer setContentSize:[drawer minContentSize]];
154 [drawer toggle:self];
155
156 return YES;
157 }
158 -(IBAction)showAddressBook:(id)sender{
159 [myAddressBookController showAddressBookWindow];
160 }
161 -(AddressBookController *)createAddressBookController{
162 AddressBookController *anAddressbookController;
163 anAddressbookController
164 = [[[AddressBookController alloc] init] autorelease];
165 [anAddressbookController window];
166 return anAddressbookController;
167 }
168
169 @end

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