Develop and Download Open Source Software

Browse CVS Repository

Diff of /undmail/guiproto/MainController.m

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

revision 1.1.1.1 by footashida, Mon Nov 11 15:40:37 2002 UTC revision 1.20 by footashida, Sun Feb 23 04:55:46 2003 UTC
# Line 1  Line 1 
1  #import "MainController.h"  #import "MainController.h"
2  #import "DummyOutlineDataSource.h"  #import "MailBoxOutlineDataSource.h"
3  #import "ToolbarItemSource.h"  #import "MainToolbarSource.h"
4  #import "IconedCell.h"  #import "IconedCell.h"
5  #import "ComposeToolbarItemSource.h"  #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 "AttachmentBrowserDelegate.h"
17    
18  @implementation MainController  @implementation MainController
19  -(void)awakeFromNib{  -(void)setupToolbar{
     DummyOutlineDataSource *ds;  
20      NSToolbar *toolbar;      NSToolbar *toolbar;
21      ToolbarItemSource *toolbarItemSource;      MainToolbarSource *mainToolbarSource;
22      ComposeToolbarItemSource *composeToolbarItemSource;      toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainToolBar"];
23            mainToolbarSource = [[MainToolbarSource alloc] initWithController:self];
24      ds = [[DummyOutlineDataSource alloc] init];      [toolbar setDelegate:mainToolbarSource];
     [folderTree setDataSource:ds];  
   
     toolbar = [[NSToolbar alloc] initWithIdentifier:@"myToolBar"];  
     toolbarItemSource = [[ToolbarItemSource alloc] initWithController:self];  
     [toolbar setDelegate:toolbarItemSource];  
25      [window setToolbar:toolbar];      [window setToolbar:toolbar];
26      [toolbar release];      [toolbar release];
27            
28      toolbar = [[NSToolbar alloc] initWithIdentifier:@"componentToolBar"];  }
29      composeToolbarItemSource = [[ComposeToolbarItemSource alloc] initWithController:self];  -(void)awakeFromNib{
30      [toolbar setDelegate:composeToolbarItemSource];      MailBoxOutlineDataSource *ds;
31      [composeWindow setToolbar:toolbar];  
32      [toolbar release];      [window center];
33        mailBoxManager = [[DUMMailBoxManager alloc] init];
34        ds = [[MailBoxOutlineDataSource alloc]
35            initWithMailBoxManager:mailBoxManager];
36        [folderTree setDataSource:ds];
37        [self setupToolbar];
38        composeControllers = [[NSMutableArray alloc] init];
39        myAddressBookController = [[self createAddressBookController] retain];
40        [myAddressBookController setWindowController:self];
41            
42        [[mailContents textStorage] setDelegate:self];
43        mailTextFormatManager = [[MailTextFormatManager sharedMailTextFormatManager] retain];
44        
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    }
54    -(void)dealloc{
55        [window release];
56        [searchWindow release];
57        [mailList release];
58        [folderTree release];
59        [mailContents release];
60        [mailBoxManager release];
61        [prefController release];
62        [myAddressBookController release];
63        [mailTextFormatManager release];
64        [super dealloc];
65    }
66    // メインウィンドウをNSWindowController化する前の一時措置
67    -(NSWindow *)window{
68        return window;
69    }
70    -(BOOL)windowShouldClose:(id)sender{
71        [composeControllers removeObject:[sender windowController]];
72        return YES;
73  }  }
74  - (void)applicationDidFinishLaunching:(NSNotification*)notif  - (void)applicationDidFinishLaunching:(NSNotification*)notif
75  {  {
76      NSTableColumn*      tableColumn;      NSTableColumn*      tableColumn;
77      IconedCell*         iconedCell;      IconedCell*         iconedCell;
78    
79      // フォルダツリーを、アイコン+文字で表示できるように、Cellの変更を行う。      // フォルダツリーを、アイコン+文字で表示できるように、Cellの変更を行う。
80        // HMDTを参考に作りました。f
81      tableColumn = [folderTree tableColumnWithIdentifier:@"folderview"];      tableColumn = [folderTree tableColumnWithIdentifier:@"folderview"];
82      iconedCell = [[[IconedCell alloc] init] autorelease];      iconedCell = [[[IconedCell alloc] init] autorelease];
83      [tableColumn setDataCell:iconedCell];      [tableColumn setDataCell:iconedCell];
84  }  }
85    
86    // 新規メッセージ作成ウィンドウを表示する。
87  -(IBAction)createNewMessage:(id)sender{  -(IBAction)createNewMessage:(id)sender{
88      [composeWindow makeKeyAndOrderFront:nil];      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    }
97    
98    // 環境設定パネルを表示する。
99    -(IBAction)showPreference:(id)sender{
100        if(prefController == nil){
101            prefController = [[PreferenceController alloc] init];
102        }
103        [prefController showWindow:self];
104    }
105    
106    // ルール設定画面を表示する
107    -(IBAction)createRule:(id)sender{
108        [self showPreference:self];
109        [prefController selectPreferenceTabWithName:@"rule_tab"];
110    }
111    
112    // アドレス帳を表示する
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  -(IBAction)findMessage:(id)sender{  
126      [searchWindow makeKeyAndOrderFront:nil];  /******************* 以下、delegateメソッド *******************************/
127    // フォルダツリー用OutlineViewのdelegateメソッド
128    - (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        return YES;
140    }
141    
142    // メールリスト用TableViewのdelegateメソッド
143    - (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex{
144        MailBoxTableDataSource *ds;
145        DUMMailBox *selectedMailBox;
146        DUMMail *mail;
147        NSAttributedString *headerString;
148        NSAttributedString *contentsString;
149        NSTextStorage *textStorage;
150        
151        ds = [aTableView dataSource];
152        selectedMailBox = [ds mailBox];
153        mail = [selectedMailBox mailAtIndex:rowIndex];
154        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            
163        [mail setIsUnread:NO];
164        [folderTree reloadData];
165        [drawer setContentSize:[drawer minContentSize]];
166        [attachmentBrowser loadColumnZero];
167        [drawer toggle:self];
168        
169        return YES;
170    }
171    
172    // attachmentViewのdelegateメソッド
173    - (void)textView:(NSTextView *)aTextView clickedOnCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame atIndex:(unsigned)charIndex{
174        [aTextView setSelectedRange:NSMakeRange(charIndex, 1)];
175  }  }
176    
177  @end  @end

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.20

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