1/*
2**  MailWindow.m
3**
4**  Copyright (c) 2001-2006 Ludovic Marcotte
5**                2014      Riccardo Mottola
6**
7**  Author: Ludovic Marcotte <ludovic@Sophos.ca>
8**          Riccardo Mottola <rm@gnu.org>
9**
10**  This program is free software; you can redistribute it and/or modify
11**  it under the terms of the GNU General Public License as published by
12**  the Free Software Foundation; either version 2 of the License, or
13**  (at your option) any later version.
14**
15**  This program is distributed in the hope that it will be useful,
16**  but WITHOUT ANY WARRANTY; without even the implied warranty of
17**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18**  GNU General Public License for more details.
19**
20** You should have received a copy of the GNU General Public License
21** along with this program.  If not, see <http://www.gnu.org/licenses/>.
22*/
23
24#import "MailWindow.h"
25
26#import "ExtendedTextView.h"
27#include "Constants.h"
28#import "LabelWidget.h"
29
30//
31//
32//
33@implementation MailWindow
34
35- (void) dealloc
36{
37  RELEASE(label);
38  RELEASE(splitView);
39  RELEASE(tableScrollView);
40  RELEASE(textView);
41  RELEASE(textScrollView);
42  RELEASE(icon);
43  [super dealloc];
44}
45
46
47//
48//
49//
50- (void) layoutWindow
51{
52  NSRect mRect;
53
54  mRect = NSMakeRect(0,0,562,230);
55
56  // We first add our 'icon' image
57  icon = [[NSButton alloc] initWithFrame: NSMakeRect(4,578,16,16)];
58  [icon setImagePosition: NSImageOnly];
59  [icon setImage: nil];
60  [icon setTitle: @""];
61  [icon setBordered: NO];
62  [icon setTarget: [NSApp delegate]];
63  [icon setAction: @selector(showConsoleWindow:)];
64  [icon setAutoresizingMask: NSViewMinYMargin];
65  [[self contentView] addSubview: icon];
66
67  label = [LabelWidget labelWidgetWithFrame: NSMakeRect(24,575,500,20)
68		       label: @""];
69  RETAIN(label);
70  [label setFont: [NSFont systemFontOfSize: 10]];
71  [label setTextColor: [NSColor darkGrayColor]];
72  [label setAutoresizingMask: NSViewMinYMargin];
73  [[self contentView] addSubview: label];
74
75  // We create our split view
76  splitView = [[NSSplitView alloc] initWithFrame: NSMakeRect(5,5,602,570)];
77  [splitView setVertical: NO];
78  [splitView setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
79
80  //
81  // We create our table scroll view and our textview object.
82  //
83  tableScrollView = [[NSScrollView alloc] initWithFrame: mRect];
84  [tableScrollView setBorderType: NSBezelBorder];
85  [tableScrollView setHasHorizontalScroller: NO];
86  [tableScrollView setHasVerticalScroller: YES];
87  [tableScrollView setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
88
89  textScrollView = [[NSScrollView alloc] initWithFrame: mRect];
90  [textScrollView setBorderType: NSBezelBorder];
91  [textScrollView setHasHorizontalScroller: NO];
92  [textScrollView setHasVerticalScroller: YES];
93
94  mRect = [[textScrollView contentView] frame];
95  textView = [[ExtendedTextView alloc] init];
96  [textView setFrame: mRect];
97  [textView setTextContainerInset: NSMakeSize(5,5)];
98  [textView setBackgroundColor: [NSColor textBackgroundColor]];
99  [textView setRichText: YES];
100  [textView setUsesFontPanel: YES];
101  [textView setDelegate: [self windowController]];
102  [textView setHorizontallyResizable: NO];
103  [textView setVerticallyResizable: YES];
104  [textView setMinSize: NSMakeSize (0, 0)];
105  [textView setMaxSize: NSMakeSize (1E7, 1E7)];
106  [textView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
107  [[textView textContainer] setContainerSize: NSMakeSize (mRect.size.width, 1E7)];
108
109  [[textView textContainer] setWidthTracksTextView: YES];
110  [textView setEditable: NO];
111  [textView setString: @""];
112
113  [textScrollView setDocumentView: textView];
114
115  [splitView addSubview: tableScrollView];
116  [splitView addSubview: textScrollView];
117
118  //FIXME: This crash the app, but I'm not sure why.
119  //[splitView adjustSubviews];
120
121  [[self contentView] addSubview: splitView];
122  [self setMinSize: NSMakeSize(600,470)];
123}
124
125@end
126