1/* 2** HeadersWindow.m 3** 4** Copyright (c) 2003 Ludovic Marcotte 5** 6** Author: Ludovic Marcotte <ludovic@Sophos.ca> 7** 8** This program is free software; you can redistribute it and/or modify 9** it under the terms of the GNU General Public License as published by 10** the Free Software Foundation; either version 2 of the License, or 11** (at your option) any later version. 12** 13** This program is distributed in the hope that it will be useful, 14** but WITHOUT ANY WARRANTY; without even the implied warranty of 15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16** GNU General Public License for more details. 17** 18** You should have received a copy of the GNU General Public License 19** along with this program. If not, see <http://www.gnu.org/licenses/>. 20*/ 21 22#include "HeadersWindow.h" 23 24#include "Constants.h" 25#include "LabelWidget.h" 26 27//const NSString *TableColumnIdentifier = @"header"; 28 29// 30// 31// 32@implementation HeadersWindow 33 34- (void) dealloc 35{ 36 NSDebugLog(@"HeadersWindow: -dealloc"); 37 38 RELEASE(showAllHeaders); 39 RELEASE(tableView); 40 RELEASE(keyField); 41 42 [super dealloc]; 43} 44 45 46// 47// 48// 49- (void) layoutWindow 50{ 51 NSButton *okButton, *cancelButton, *removeShown, *addShown, *addDefaults, *moveUp, *moveDown; 52 NSTableColumn *tableColumn; 53 NSScrollView *scrollView; 54 LabelWidget *keyLabel; 55 NSBox *box; 56 57 // 58 // Our visible header box 59 // 60 box = [[NSBox alloc] initWithFrame: NSMakeRect(5,45,430,245)]; 61 [box setContentViewMargins: NSMakeSize(5,0)]; 62 [box setTitlePosition: NSAtTop]; 63 [box setTitle: _(@"Shown headers while viewing a mail")]; 64 [box setBorderType: NSGrooveBorder]; 65 66 showAllHeaders = [[NSButton alloc] initWithFrame: NSMakeRect(5,200,200,ButtonHeight)]; 67 [showAllHeaders setButtonType: NSSwitchButton]; 68 [showAllHeaders setBordered: NO]; 69 [showAllHeaders setTitle: _(@"Show all headers")]; 70 [box addSubview: showAllHeaders]; 71 72 addShown = [[NSButton alloc] initWithFrame: NSMakeRect(5,5,80,ButtonHeight)]; 73 [addShown setStringValue: _(@"Add")]; 74 [addShown setTarget: [self windowController]]; 75 [addShown setAction:@selector(addShown:)]; 76 [[box contentView] addSubview: addShown]; 77 RELEASE(addShown); 78 79 removeShown = [[NSButton alloc] initWithFrame: NSMakeRect(95,5,80,ButtonHeight)]; 80 [removeShown setStringValue: _(@"Remove")]; 81 [removeShown setTarget: [self windowController]]; 82 [removeShown setAction:@selector(removeShown:)]; 83 [[box contentView] addSubview: removeShown]; 84 RELEASE(removeShown); 85 86 addDefaults = [[NSButton alloc] initWithFrame: NSMakeRect(185,5,80,ButtonHeight)]; 87 [addDefaults setStringValue: _(@"Defaults")]; 88 [addDefaults setTarget: [self windowController]]; 89 [addDefaults setAction:@selector(addDefaults:)]; 90 [[box contentView] addSubview: addDefaults]; 91 RELEASE(addDefaults); 92 93 moveUp = [[NSButton alloc] initWithFrame:NSMakeRect(275,5,64,ButtonHeight)]; 94 [moveUp setTitle: @""]; 95 [moveUp setImagePosition: NSImageOnly]; 96 [moveUp setImage: [NSImage imageNamed: @"sort_up.tiff"]]; 97 [moveUp setTarget: [self windowController]]; 98 [moveUp setAction: @selector(moveUp:)]; 99 [moveUp setAutoresizingMask: NSViewMinYMargin]; 100 [[box contentView] addSubview: moveUp]; 101 RELEASE(moveUp); 102 103 moveDown = [[NSButton alloc] initWithFrame:NSMakeRect(349,5,64,ButtonHeight)]; 104 [moveDown setTitle: @""]; 105 [moveDown setImagePosition: NSImageOnly]; 106 [moveDown setImage: [NSImage imageNamed: @"sort_down.tiff"]]; 107 [moveDown setTarget: [self windowController]]; 108 [moveDown setAction: @selector(moveDown:)]; 109 [moveDown setAutoresizingMask: NSViewMinYMargin]; 110 [[box contentView] addSubview: moveDown]; 111 RELEASE(moveDown); 112 113 keyLabel = [LabelWidget labelWidgetWithFrame: NSMakeRect(5,40,60,TextFieldHeight) 114 label: _(@"Key:") ]; 115 [[box contentView] addSubview: keyLabel]; 116 117 keyField = [[NSTextField alloc] initWithFrame: NSMakeRect(70,40,340,TextFieldHeight)]; 118 [[box contentView] addSubview: keyField]; 119 120 tableColumn = [[NSTableColumn alloc] initWithIdentifier: (id) @"header"]; 121 AUTORELEASE(tableColumn); 122 [tableColumn setEditable: YES]; 123 [[tableColumn headerCell] setStringValue: _(@"Shown Headers")]; 124 [tableColumn setWidth: 240]; 125 126 tableView = [[NSTableView alloc] initWithFrame: NSMakeRect(5,75,405,120)]; 127 [tableView setDrawsGrid:NO]; 128 [tableView setAllowsColumnSelection: NO]; 129 [tableView setAllowsColumnReordering: NO]; 130 [tableView setAllowsEmptySelection: NO]; 131 [tableView setAllowsMultipleSelection: NO]; 132 [tableView addTableColumn: tableColumn]; 133 [tableView setDataSource: [self windowController]]; 134 [tableView setDelegate: [self windowController]]; 135 136 scrollView = [[NSScrollView alloc] initWithFrame: NSMakeRect(5,75,405,120)]; 137 [scrollView setBorderType: NSBezelBorder]; 138 [scrollView setHasHorizontalScroller: NO]; 139 [scrollView setHasVerticalScroller: YES]; 140 [scrollView setDocumentView: tableView]; 141 [[box contentView] addSubview: scrollView]; 142 RELEASE(scrollView); 143 144 [[self contentView] addSubview: box]; 145 RELEASE(box); 146 147 cancelButton = [[NSButton alloc] initWithFrame: NSMakeRect(280,10,75,ButtonHeight)]; 148 [cancelButton setButtonType: NSMomentaryPushButton]; 149 [cancelButton setKeyEquivalent: @"\e"]; 150 [cancelButton setTitle: _(@"Cancel")]; 151 [cancelButton setTarget: [self windowController]]; 152 [cancelButton setAction: @selector(cancelClicked:)]; 153 [[self contentView] addSubview: cancelButton]; 154 RELEASE(cancelButton); 155 156 okButton = [[NSButton alloc] initWithFrame: NSMakeRect(360,10,75,ButtonHeight)]; 157 [okButton setButtonType: NSMomentaryPushButton]; 158 [okButton setKeyEquivalent: @"\r"]; 159 [okButton setImagePosition: NSImageRight]; 160 [okButton setImage: [NSImage imageNamed: @"common_ret"]]; 161 [okButton setAlternateImage: [NSImage imageNamed: @"common_retH"]]; 162 [okButton setTitle: _(@"OK")]; 163 [okButton setTarget: [self windowController]]; 164 [okButton setAction: @selector(okClicked:)]; 165 [[self contentView] addSubview:okButton]; 166 RELEASE(okButton); 167} 168 169@end 170