jjgod / JJWaveView

A WaveView modified from ArkWaveView

jjgod (author)
Mon May 04 01:30:14 -0700 2009
commit  83912119c67c9fbaf3f87db573e31febe23210c1
tree    ee91fc402b641981a6ad5e216e32e08d95152e21
parent  a551f4b15bdd359073a73a3f3a5de28c74ecf543
JJWaveView / ArkLinePrefs.m
100644 167 lines (147 sloc) 3.755 kb
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Arkonnekt AppKit, Cocoa classes for audio programming.
// Copyright (C) 2005 Jeremy Jurksztowicz
//
// This library is free software; you can redistribute it and/or modify it under the terms of the
// GNU Lesser General Public License as published by the Free Software Foundation; either version
// 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License along with this library;
// if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
// 02111-1307 USA
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
 
#import "ArkLinePrefs.h"
 
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Init, copy and destroy
//
@implementation ArkLinePrefs
 
- (id) init
{
if(self = [super init]) {
drawLine = YES;
width = 2.0;
isDashed = NO;
dash = 0;
dashLength = 0;
color = [[NSColor blackColor] retain];
 
notifyDelegate = NO;
}
return self;
}
 
- (void) dealloc
{
if(dash) free(dash);
[color release];
[super dealloc];
}
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Accessors
//
- (id) delegate
{
return del;
}
 
- (void) setDelegate:(id)newDel
{
if(newDel != del) {
del = newDel;
if(del == nil || [del respondsToSelector:@selector(linePrefsDidChange:)] == NO) {
notifyDelegate = NO;
NSLog(@"ArkLinePrefs delegate does not respond to selector, or is nil.");
}
else notifyDelegate = YES;
}
}
 
- (BOOL) drawLine
{
return drawLine;
}
 
- (void) setDrawLine:(BOOL)draw
{
if(draw != drawLine) {
drawLine = draw;
 
if(notifyDelegate)
[del linePrefsDidChange:self];
}
}
 
- (float) width
{
return width;
}
 
- (void) setWidth:(float)newWidth
{
if(newWidth != width) {
width = newWidth;
 
if(notifyDelegate)
[del linePrefsDidChange:self];
}
}
 
- (BOOL) isDashed
{
return isDashed;
}
 
- (BOOL) getDash:(float**)dashPtr count:(int*)len
{
if(dashPtr && len)
{
if(*dashPtr == NULL) {
*dashPtr = dash;
*len = dashLength;
return YES;
}
else if(*len >= dashLength) {
int l = dashLength;
while(l--) (*dashPtr)[l] = dash[l];
*len = dashLength;
return YES;
}
}
// The user only wants the length of dash
else if(len)
{
*len = dashLength;
return YES;
}
return NO;
}
 
- (void) setDash:(float*)newDash count:(int)len
{
if(dash) {
free(dash);
dash = 0;
dashLength = 0;
}
if(newDash && len) {
dash = malloc(len*sizeof(float));
dashLength = len;
while(len) {
len -= 1;
dash[len] = newDash[len];
}
isDashed = YES;
}
else isDashed = NO;
 
if(notifyDelegate)
[del linePrefsDidChange:self];
}
 
- (NSColor*) color
{
return color;
}
 
- (void) setColor:(NSColor*)newColor
{
if(newColor != color) {
[color autorelease];
color = [newColor retain];
 
if(notifyDelegate)
[del linePrefsDidChange:self];
}
}
 
@end