2
* peripheraldrawer.m - PeripheralDrawer
5
* Christian Vogelgsang <chris@vogelgsang.org>
6
* Michael Klein <michael.klein@puffin.lb.shuttle.de>
8
* This file is part of VICE, the Versatile Commodore Emulator.
9
* See README for copyright notice.
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
32
#import <Cocoa/Cocoa.h>
33
#import "peripheraldrawer.h"
34
#import "vicenotifications.h"
35
#import "vicewindow.h"
37
#define PERIPH_WIDTH 100
38
#define PERIPH_HEIGHT 22
40
/* ============================================================== */
42
@interface FlippedView : NSView
45
@implementation FlippedView : NSView
52
/* ============================================================== */
54
@implementation PeripheralDrawer
56
- (id)initWithPreferredEdge:(NSRectEdge)edge
58
if ((self = [super initWithContentSize:NSMakeSize(PERIPH_WIDTH, PERIPH_HEIGHT)
59
preferredEdge:edge]) != nil)
61
[self setMinContentSize:NSMakeSize(PERIPH_WIDTH, 5*PERIPH_HEIGHT)];
63
led_color[0] = [[NSColor redColor] retain];
64
led_color[1] = [[NSColor greenColor] retain];
66
FlippedView * v = [[FlippedView alloc]
67
initWithFrame:NSMakeRect(0,0,PERIPH_WIDTH,PERIPH_HEIGHT)];
68
[v setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
70
[[NSNotificationCenter defaultCenter] addObserver:self
71
selector:@selector(enableDriveStatus:)
72
name:VICEEnableDriveStatusNotification
76
for (i = 0; i < DRIVE_NUM; i++)
78
NSRect rect = NSMakeRect(0, 0, PERIPH_WIDTH, PERIPH_HEIGHT*2);
79
drive_view[i] = [[DriveView alloc] initWithFrame:rect driveNumber:i];
80
[drive_view[i] setAutoresizingMask: NSViewWidthSizable];
83
tape_view = [[TapeView alloc] initWithFrame:NSMakeRect(0, 0, PERIPH_WIDTH, PERIPH_HEIGHT)];
84
[tape_view setAutoresizingMask: NSViewWidthSizable];
86
// [self setTapeStatus:0];
87
[v addSubview:tape_view];
89
[self setContentView:v];
98
[led_color[0] release];
99
[led_color[1] release];
101
for (i = 0; i < DRIVE_NUM; i++)
103
[drive_view[i] release];
110
- (void)enableDriveStatus:(NSNotification*)notification
112
NSDictionary * dict = [notification userInfo];
113
int drive_led_color = [[dict objectForKey:@"drive_led_color"] intValue];
114
int enable = [[dict objectForKey:@"enabled_drives"] intValue];
116
float width = NSWidth([[self contentView] bounds]);
119
for(i = 0; i < DRIVE_NUM; i++)
124
int colorIndex = (drive_led_color & flag) != 0 ? 1 : 0;
125
[[self contentView] addSubview:drive_view[i]];
126
[drive_view[i] initLedColor:led_color[colorIndex]];
127
[drive_view[i] setFrame:NSMakeRect(0, count * PERIPH_HEIGHT * 2, width, PERIPH_HEIGHT*2)];
132
[drive_view[i] removeFromSuperview];
136
// reposition tape display and rec/play field
137
[tape_view setFrame:NSMakeRect(0, count++ * PERIPH_HEIGHT * 2, width, PERIPH_HEIGHT)];
138
[[self contentView] setNeedsDisplay:YES];
141
- (void)setTapeStatus:(int)status
143
[tape_view setEnabled:status];
144
[[self contentView] setNeedsDisplay:YES];