1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
/*
PrefsWindow.m
Preferences panel class
Copyright (C) 2001 Dusk to Dawn Computing, Inc.
Author: Jeff Teunissen <deek@d2dc.net>
Date: 11 Nov 2001
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
static const char rcsid[] =
"$Id: PrefsWindow.m,v 1.2 2003/07/09 18:27:47 Deek Exp $";
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <Foundation/NSGeometry.h>
#import <AppKit/NSButton.h>
#import <AppKit/NSButtonCell.h>
#import <AppKit/NSFont.h>
#import <AppKit/NSMatrix.h>
#import <AppKit/NSScrollView.h>
#import "BundleController.h"
#import "PrefsWindow.h"
@implementation PrefsWindow
- (void) initUI
{
NSButtonCell *prototype;
NSScrollView *iconScrollView;
_topTag = 0; // This is for the matrix
/*
Window dimensions:
content view size: (400, 300)
8-pixel space on all sides
Box content view is is 265 pixels high, 500 wide
Scroll area is 86 pixels tall, 500 wide
*/
/* We're going top to bottom here... */
// Prototype button for the matrix
prototype = [[[NSButtonCell alloc] init] autorelease];
[prototype setButtonType: NSOnOffButton];
[prototype setImagePosition: NSImageOverlaps];
// The matrix itself -- horizontal
prefsViewList = [[NSMatrix alloc] initWithFrame: NSMakeRect (0, 0, 560, 70)];
[prefsViewList setAllowsEmptySelection: YES];
[prefsViewList setCellSize: NSMakeSize (70, 70)];
[prefsViewList setMode: NSRadioModeMatrix];
[prefsViewList setPrototype: prototype];
[prefsViewList setAction: @selector(cellWasClicked:)];
[prefsViewList setTarget: [self windowController]];
iconScrollView = [[NSScrollView alloc] initWithFrame: NSMakeRect (8, 202, 384, 92)];
[iconScrollView autorelease];
[iconScrollView setHasHorizontalScroller: YES];
[iconScrollView setHasVerticalScroller: NO];
[iconScrollView setDocumentView: prefsViewList];
[[self contentView] addSubview: iconScrollView];
prefsViewBox = [[NSBox alloc] initWithFrame: NSMakeRect (-2, -2, 404, 196)];
[prefsViewBox setTitlePosition: NSNoTitle];
[prefsViewBox setBorderType: NSGrooveBorder];
[prefsViewBox setContentViewMargins: NSMakeSize (8, 8)];
NSLog (@"prefsViewBox bounds: %@", NSStringFromRect ([[prefsViewBox contentView] bounds]));
[[self contentView] addSubview: prefsViewBox];
}
- (void) dealloc
{
NSDebugLog (@"PrefsWindow -dealloc");
[prefsViewBox release];
[super dealloc];
}
- (void) addPrefsViewButton: (id <PrefsModule>) aController
{
NSButtonCell *button = [[NSButtonCell alloc] init];
[button setTag: _topTag++];
[button setButtonType: NSOnOffButton];
[button setImage: [aController buttonImage]];
[button setImagePosition: NSImageOnly];
[button setTarget: aController];
[button setAction: [aController buttonAction]];
[prefsViewList addColumnWithCells: [NSArray arrayWithObject: button]];
[prefsViewList sizeToCells];
[prefsViewList setNeedsDisplay: YES];
}
- (NSBox *) prefsViewBox
{
return prefsViewBox;
}
- (NSMatrix *) prefsViewList
{
return prefsViewList;
}
@end
|