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.20 - (hide annotations) (download)
Sun Feb 23 04:55:46 2003 UTC (21 years, 1 month ago) by footashida
Branch: MAIN
CVS Tags: HEAD
Changes since 1.19: +43 -35 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.20 #import "AttachmentBrowserDelegate.h"
17    
18 footashida 1.1 @implementation MainController
19 footashida 1.13 -(void)setupToolbar{
20 footashida 1.1 NSToolbar *toolbar;
21 footashida 1.2 MainToolbarSource *mainToolbarSource;
22 footashida 1.5 toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"];
23 footashida 1.2 mainToolbarSource = [[MainToolbarSource alloc] initWithController:self];
24     [toolbar setDelegate:mainToolbarSource];
25 footashida 1.1 [window setToolbar:toolbar];
26     [toolbar release];
27    
28 footashida 1.13 }
29     -(void)awakeFromNib{
30     MailBoxOutlineDataSource *ds;
31 footashida 1.18
32 footashida 1.13 [window center];
33     mailBoxManager = [[DUMMailBoxManager alloc] init];
34     ds = [[MailBoxOutlineDataSource alloc]
35     initWithMailBoxManager:mailBoxManager];
36     [folderTree setDataSource:ds];
37     [self setupToolbar];
38 footashida 1.17 composeControllers = [[NSMutableArray alloc] init];
39 footashida 1.19 myAddressBookController = [[self createAddressBookController] retain];
40     [myAddressBookController setWindowController:self];
41 footashida 1.1
42 footashida 1.17 [[mailContents textStorage] setDelegate:self];
43 footashida 1.19 mailTextFormatManager = [[MailTextFormatManager sharedMailTextFormatManager] retain];
44 footashida 1.20
45     attachmentBrowserDelegate
46     = [[AttachmentBrowserDelegate alloc] initWithBrowser:attachmentBrowser];
47     [attachmentBrowserDelegate setBrowserElements:
48     [NSArray arrayWithObjects:@"abc", @"def", @"ghi", @"jkl", nil]];
49     [attachmentBrowser setDelegate:attachmentBrowserDelegate];
50    
51     [drawer setContentView:attachmentView];
52    
53 footashida 1.1 }
54 footashida 1.15 -(void)dealloc{
55     [window release];
56     [searchWindow release];
57     [mailList release];
58     [folderTree release];
59     [mailContents release];
60     [mailBoxManager release];
61     [prefController release];
62 footashida 1.19 [myAddressBookController release];
63 footashida 1.17 [mailTextFormatManager release];
64 footashida 1.15 [super dealloc];
65     }
66 footashida 1.19 // ���C���E�B���h�E��NSWindowController�������O�������[�u
67     -(NSWindow *)window{
68     return window;
69     }
70 footashida 1.17 -(BOOL)windowShouldClose:(id)sender{
71     [composeControllers removeObject:[sender windowController]];
72     return YES;
73     }
74 footashida 1.1 - (void)applicationDidFinishLaunching:(NSNotification*)notif
75     {
76     NSTableColumn* tableColumn;
77     IconedCell* iconedCell;
78 footashida 1.20
79 footashida 1.1 // �t�H���_�c���[���A�A�C�R��+�������\���������������ACell�����X���s���B
80 footashida 1.20 // HMDT���Q�l�������������Bf
81 footashida 1.1 tableColumn = [folderTree tableColumnWithIdentifier:@"folderview"];
82     iconedCell = [[[IconedCell alloc] init] autorelease];
83     [tableColumn setDataCell:iconedCell];
84     }
85 footashida 1.20
86     // �V�K���b�Z�[�W�����E�B���h�E���\�������B
87 footashida 1.1 -(IBAction)createNewMessage:(id)sender{
88 footashida 1.19 AddressBookController *anAddressBookController = [self createAddressBookController];
89     ComposeController *aComposeController = [[ComposeController alloc] init];
90    
91     [aComposeController setAddressBookController:anAddressBookController];
92     [anAddressBookController setWindowController:aComposeController];
93     [aComposeController createNewMessageWithHeader:nil contents:nil];
94     [composeControllers addObject:aComposeController];
95     [aComposeController release];
96 footashida 1.1 }
97 footashida 1.20
98     // ���������p�l�����\�������B
99 footashida 1.2 -(IBAction)showPreference:(id)sender{
100 footashida 1.12 if(prefController == nil){
101     prefController = [[PreferenceController alloc] init];
102 footashida 1.3 }
103 footashida 1.12 [prefController showWindow:self];
104 footashida 1.1 }
105 footashida 1.20
106     // ���[�������������\������
107 footashida 1.9 -(IBAction)createRule:(id)sender{
108     [self showPreference:self];
109 footashida 1.12 [prefController selectPreferenceTabWithName:@"rule_tab"];
110     }
111 footashida 1.20
112     // �A�h���X�����\������
113     -(IBAction)showAddressBook:(id)sender{
114     [myAddressBookController showAddressBookWindow];
115     }
116    
117     // AddressBookController������
118     -(AddressBookController *)createAddressBookController{
119     AddressBookController *anAddressbookController;
120     anAddressbookController
121     = [[[AddressBookController alloc] init] autorelease];
122     [anAddressbookController window];
123     return anAddressbookController;
124     }
125    
126     /******************* �����Adelegate���\�b�h *******************************/
127     // �t�H���_�c���[�pOutlineView��delegate���\�b�h
128 footashida 1.12 - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item{
129     MailBoxTableDataSource *ds;
130    
131     if([mailList dataSource] == nil){
132     ds = [[MailBoxTableDataSource alloc] initWithMailBox:item];
133     [mailList setDataSource:ds];
134     }else{
135     ds = [mailList dataSource];
136     [ds changeMailBox:item];
137     }
138     [mailList reloadData];
139 footashida 1.13 return YES;
140     }
141 footashida 1.20
142     // ���[�����X�g�pTableView��delegate���\�b�h
143 footashida 1.13 - (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex{
144     MailBoxTableDataSource *ds;
145     DUMMailBox *selectedMailBox;
146     DUMMail *mail;
147 footashida 1.17 NSAttributedString *headerString;
148     NSAttributedString *contentsString;
149     NSTextStorage *textStorage;
150 footashida 1.13
151     ds = [aTableView dataSource];
152     selectedMailBox = [ds mailBox];
153     mail = [selectedMailBox mailAtIndex:rowIndex];
154 footashida 1.17 headerString = [mailTextFormatManager formatHeader:[mail headerText]];
155     contentsString = [mailTextFormatManager formatContents:[mail content]];
156     textStorage = [mailContents textStorage];
157     [textStorage beginEditing];
158     [textStorage deleteCharactersInRange:NSMakeRange(0, [textStorage length])];
159     [textStorage appendAttributedString:headerString];
160     [textStorage appendAttributedString:contentsString];
161     [textStorage endEditing];
162 footashida 1.19
163 footashida 1.15 [mail setIsUnread:NO];
164     [folderTree reloadData];
165 footashida 1.19 [drawer setContentSize:[drawer minContentSize]];
166 footashida 1.20 [attachmentBrowser loadColumnZero];
167 footashida 1.19 [drawer toggle:self];
168    
169 footashida 1.12 return YES;
170 footashida 1.14 }
171 footashida 1.20
172     // attachmentView��delegate���\�b�h
173     - (void)textView:(NSTextView *)aTextView clickedOnCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame atIndex:(unsigned)charIndex{
174     [aTextView setSelectedRange:NSMakeRange(charIndex, 1)];
175 footashida 1.9 }
176 footashida 1.19
177 footashida 1.17 @end

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