1/* 2** PreferencesWindow.m 3** 4** Copyright (c) 2001-2005 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 "PreferencesWindow.h" 23 24#include "Constants.h" 25 26 27// 28// 29// 30@implementation PreferencesWindow 31 32- (void) dealloc 33{ 34 RELEASE(box); 35 RELEASE(matrix); 36 RELEASE(scrollView); 37 RELEASE(expert); 38 [super dealloc]; 39} 40 41// 42// 43// 44- (void) layoutWindow 45{ 46 NSButton *ok, *apply, *cancel; 47 NSButtonCell *cell; 48 49 box = [[NSBox alloc] initWithFrame: NSMakeRect(8,41,455,260)]; 50 [box setTitlePosition: NSAtTop]; 51 [box setBorderType: NSGrooveBorder]; 52 [[self contentView] addSubview: box]; 53 54 cell = [[NSButtonCell alloc] init]; 55 AUTORELEASE(cell); 56 [cell setHighlightsBy: NSChangeBackgroundCellMask]; 57 [cell setShowsStateBy: NSChangeBackgroundCellMask]; 58 [cell setImagePosition: NSImageAbove]; 59 60 matrix = [[NSMatrix alloc] initWithFrame: NSMakeRect(8,306,455,86) 61 mode: NSRadioModeMatrix 62 prototype: cell 63 numberOfRows: 1 64 numberOfColumns: 10]; 65 [matrix setTarget: [self windowController]]; 66 [matrix setCellSize: NSMakeSize(64,64)]; 67 [matrix setAction: @selector(handleCellAction:)]; 68 69 scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(8,306,455,86)]; 70 [scrollView setBorderType: NSBezelBorder]; 71 [scrollView setHasHorizontalScroller: YES]; 72 [scrollView setHasVerticalScroller: NO]; 73 [scrollView setDocumentView: matrix]; 74 [[self contentView] addSubview: scrollView]; 75 76 // We create the buttons 77 expert = [[NSButton alloc] initWithFrame:NSMakeRect(8,8,80,ButtonHeight)]; 78 [expert setTitle: _(@"Expert")]; 79 [expert setTarget: [self windowController]]; 80 [expert setAction: @selector(expertClicked:)]; 81 [[self contentView] addSubview: expert]; 82 83 apply = [[NSButton alloc] initWithFrame:NSMakeRect(230,8,75,ButtonHeight)]; 84 [apply setTitle: _(@"Apply")]; 85 [apply setTarget: [self windowController]]; 86 [apply setAction: @selector(savePreferences:)]; 87 [[self contentView] addSubview: apply]; 88 RELEASE(apply); 89 90 cancel = [[NSButton alloc] initWithFrame:NSMakeRect(310,8,75,ButtonHeight)]; 91 [cancel setTitle: _(@"Cancel")]; 92 [cancel setKeyEquivalent: @"\e"]; 93 [cancel setTarget: [self windowController]]; 94 [cancel setAction: @selector(cancelClicked:)]; 95 [[self contentView] addSubview: cancel]; 96 RELEASE(cancel); 97 98 ok = [[NSButton alloc] initWithFrame:NSMakeRect(390,8,75,ButtonHeight)]; 99 [ok setButtonType: NSMomentaryPushButton]; 100 [ok setKeyEquivalent: @"\r"]; 101 [ok setImagePosition: NSImageRight]; 102 [ok setImage: [NSImage imageNamed: @"common_ret"]]; 103 [ok setAlternateImage: [NSImage imageNamed: @"common_retH"]]; 104 [ok setTitle: _(@"OK")]; 105 [ok setTarget: [self windowController]]; 106 [ok setAction: @selector(saveAndClose:)]; 107 [[self contentView] addSubview: ok]; 108 RELEASE(ok); 109} 110 111@end 112