| |
Changeset 89
- Timestamp:
- 06/06/07 19:07:36
(1 year ago)
- Author:
- mike
- Message:
[new] new icons (Andi)
[fix] CpuView? adapted to new icons
[fix] new default icon set for qControl
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r88 |
r89 |
|
| | 1 | Q-0.9.0d89 |
|---|
| | 2 | [new] new icons (Andi) |
|---|
| | 3 | [fix] CpuView adapted to new icons |
|---|
| | 4 | [fix] new default icon set for qControl |
|---|
| | 5 | |
|---|
| 1 | 6 | Q-0.9.0d88 |
|---|
| 2 | 7 | [fix] changelog update |
|---|
| r62 |
r89 |
|
| 41 | 41 | - (void) encodeWithCoder:(NSCoder *) coder |
|---|
| 42 | 42 | { |
|---|
| 43 | | // NSLog(@"cocoaCpuView: encodeWithCoder"); |
|---|
| 44 | | |
|---|
| 45 | | [super encodeWithCoder:coder]; |
|---|
| 46 | | [coder encodeObject: [self image] forKey:@"regularImage"]; |
|---|
| | 43 | // NSLog(@"cocoaCpuView: encodeWithCoder"); |
|---|
| | 44 | |
|---|
| | 45 | [super encodeWithCoder:coder]; |
|---|
| | 46 | [coder encodeObject: [self image] forKey:@"regularImage"]; |
|---|
| 47 | 47 | } |
|---|
| 48 | 48 | |
|---|
| 49 | 49 | - (id) initWithCoder:(NSCoder *) coder |
|---|
| 50 | 50 | { |
|---|
| 51 | | // NSLog(@"cocoaCpuView: initWithCoder"); |
|---|
| 52 | | |
|---|
| 53 | | if ((self = [super initWithCoder:coder])) { |
|---|
| 54 | | regularImage = [[coder decodeObjectForKey:@"regularImage"] retain]; |
|---|
| 55 | | smallImage = nil; |
|---|
| 56 | | ctlSize = NSRegularControlSize; |
|---|
| 57 | | |
|---|
| 58 | | return self; |
|---|
| 59 | | } |
|---|
| 60 | | return nil; |
|---|
| | 51 | // NSLog(@"cocoaCpuView: initWithCoder"); |
|---|
| | 52 | |
|---|
| | 53 | if ((self = [super initWithCoder:coder])) { |
|---|
| | 54 | regularImage = [[coder decodeObjectForKey:@"regularImage"] retain]; |
|---|
| | 55 | smallImage = nil; |
|---|
| | 56 | ctlSize = NSRegularControlSize; |
|---|
| | 57 | |
|---|
| | 58 | return self; |
|---|
| | 59 | } |
|---|
| | 60 | return nil; |
|---|
| 61 | 61 | } |
|---|
| 62 | 62 | |
|---|
| 63 | 63 | - (id) initWithImage:(NSImage *) image |
|---|
| 64 | 64 | { |
|---|
| 65 | | // NSLog(@"cocoaPopUpView: initWithImage"); |
|---|
| 66 | | |
|---|
| 67 | | if( ( self = [super initWithFrame:NSMakeRect(0.,0.,[image size].width,[image size].height)] ) ) { |
|---|
| 68 | | [self setImage:image]; |
|---|
| 69 | | return self; |
|---|
| 70 | | } |
|---|
| 71 | | |
|---|
| 72 | | return nil; |
|---|
| | 65 | // NSLog(@"cocoaPopUpView: initWithImage"); |
|---|
| | 66 | |
|---|
| | 67 | if( ( self = [super initWithFrame:NSMakeRect(0.,0.,[image size].width,[image size].height)] ) ) { |
|---|
| | 68 | [self setImage:image]; |
|---|
| | 69 | return self; |
|---|
| | 70 | } |
|---|
| | 71 | |
|---|
| | 72 | return nil; |
|---|
| 73 | 73 | } |
|---|
| 74 | 74 | |
|---|
| 75 | 75 | - (void) dealloc |
|---|
| 76 | 76 | { |
|---|
| 77 | | // NSLog(@"cocoaCpuView: dealloc"); |
|---|
| 78 | | |
|---|
| 79 | | [regularImage release]; |
|---|
| 80 | | [smallImage release]; |
|---|
| 81 | | |
|---|
| 82 | | regularImage = nil; |
|---|
| 83 | | smallImage = nil; |
|---|
| 84 | | |
|---|
| 85 | | [super dealloc]; |
|---|
| | 77 | // NSLog(@"cocoaCpuView: dealloc"); |
|---|
| | 78 | |
|---|
| | 79 | [regularImage release]; |
|---|
| | 80 | [smallImage release]; |
|---|
| | 81 | |
|---|
| | 82 | regularImage = nil; |
|---|
| | 83 | smallImage = nil; |
|---|
| | 84 | |
|---|
| | 85 | [super dealloc]; |
|---|
| 86 | 86 | } |
|---|
| 87 | 87 | |
|---|
| 88 | 88 | - (void) drawRect:(NSRect) rect |
|---|
| 89 | 89 | { |
|---|
| 90 | | // NSLog(@"cocoaCpuView: drawRect"); |
|---|
| 91 | | |
|---|
| | 90 | // NSLog(@"cocoaCpuView: drawRect"); |
|---|
| | 91 | |
|---|
| | 92 | /* CPU Activity */ |
|---|
| 92 | 93 | NSBezierPath* path = [NSBezierPath bezierPath]; |
|---|
| 93 | | |
|---|
| 94 | | /* HD Activity */ |
|---|
| 95 | | BlockDriverState *bs; |
|---|
| 96 | | bs = bdrv_find([@"hda" cString]); |
|---|
| 97 | | if (bs) { |
|---|
| 98 | | path = [NSBezierPath bezierPath]; |
|---|
| 99 | | if( ctlSize == NSRegularControlSize ) { |
|---|
| 100 | | [path setLineWidth:2.0]; |
|---|
| 101 | | [path appendBezierPathWithOvalInRect:NSMakeRect(1,1,16,16)]; |
|---|
| 102 | | } else { |
|---|
| 103 | | [path appendBezierPathWithOvalInRect:NSMakeRect(1,1,12,12)]; |
|---|
| 104 | | } |
|---|
| 105 | | [[NSColor blackColor] setStroke]; |
|---|
| 106 | | if (bs->activityLED) { |
|---|
| 107 | | [[NSColor greenColor] setFill]; |
|---|
| 108 | | bs->activityLED = 0; |
|---|
| 109 | | } else { |
|---|
| 110 | | [[NSColor yellowColor] setFill]; |
|---|
| 111 | | } |
|---|
| 112 | | [path fill]; |
|---|
| 113 | | [path stroke]; |
|---|
| 114 | | } |
|---|
| 115 | | |
|---|
| 116 | | /* CD-ROM Activity */ |
|---|
| 117 | | // BlockDriverState *bs; |
|---|
| 118 | | bs = bdrv_find([@"cdrom" cString]); |
|---|
| 119 | | if (bs) { |
|---|
| 120 | | path = [NSBezierPath bezierPath]; |
|---|
| 121 | | if( ctlSize == NSRegularControlSize ) { |
|---|
| 122 | | [path setLineWidth:2.0]; |
|---|
| 123 | | [path appendBezierPathWithOvalInRect:NSMakeRect(39,1,16,16)]; |
|---|
| 124 | | } else { |
|---|
| 125 | | [path appendBezierPathWithOvalInRect:NSMakeRect(29,1,12,12)]; |
|---|
| 126 | | } |
|---|
| 127 | | [[NSColor blackColor] setStroke]; |
|---|
| 128 | | if (bs->activityLED) { |
|---|
| 129 | | [[NSColor greenColor] setFill]; |
|---|
| 130 | | bs->activityLED = 0; |
|---|
| 131 | | } else { |
|---|
| 132 | | [[NSColor yellowColor] setFill]; |
|---|
| 133 | | } |
|---|
| 134 | | [path fill]; |
|---|
| 135 | | [path stroke]; |
|---|
| 136 | | path = [NSBezierPath bezierPath]; |
|---|
| 137 | | if( ctlSize == NSRegularControlSize ) { |
|---|
| 138 | | [path appendBezierPathWithOvalInRect:NSMakeRect(44,6,6,6)]; |
|---|
| 139 | | } else { |
|---|
| 140 | | [path appendBezierPathWithOvalInRect:NSMakeRect(33,5,4,4)]; |
|---|
| 141 | | } |
|---|
| 142 | | [[NSColor blackColor] setFill]; |
|---|
| 143 | | [path fill]; |
|---|
| 144 | | } |
|---|
| 145 | | |
|---|
| 146 | | /* CPU Activity */ |
|---|
| 147 | 94 | kern_return_t error; |
|---|
| 148 | 95 | struct thread_basic_info tbi; |
|---|
| … | … | |
| 181 | 128 | if (error != KERN_SUCCESS) |
|---|
| 182 | 129 | NSLog(@"Call to thread_info() failed"); |
|---|
| 183 | | #endif |
|---|
| | 130 | #endif |
|---|
| 184 | 131 | cpuUsage += tbi.cpu_usage; |
|---|
| 185 | 132 | } |
|---|
| 186 | 133 | cpuUsage = cpuUsage * 0.05; |
|---|
| 187 | 134 | |
|---|
| 188 | | [[NSColor blackColor] set]; |
|---|
| 189 | | path = [NSBezierPath bezierPath]; |
|---|
| 190 | | |
|---|
| 191 | | if( ctlSize == NSRegularControlSize ) { |
|---|
| 192 | | [regularImage compositeToPoint:NSMakePoint(12,0) operation:NSCompositeSourceOver]; |
|---|
| 193 | | [path moveToPoint:NSMakePoint(28, 0)]; |
|---|
| 194 | | [path lineToPoint:NSMakePoint(28. - cos(pi / 180. * (65. + cpuUsage)) * 28., sin(pi / 180. * (65. + cpuUsage)) * 28.)]; |
|---|
| 195 | | } else { |
|---|
| 196 | | [smallImage compositeToPoint:NSMakePoint(9,0) operation:NSCompositeSourceOver]; |
|---|
| 197 | | [path moveToPoint:NSMakePoint(21, 0)]; |
|---|
| 198 | | [path lineToPoint:NSMakePoint(21. - cos(pi / 180. * (65. + cpuUsage)) * 20., sin(pi / 180. * (65. + cpuUsage)) * 20.)]; |
|---|
| 199 | | } |
|---|
| 200 | | [path stroke]; |
|---|
| 201 | | |
|---|
| | 135 | [[NSColor blackColor] set]; |
|---|
| | 136 | path = [NSBezierPath bezierPath]; |
|---|
| | 137 | |
|---|
| | 138 | if( ctlSize == NSRegularControlSize ) { |
|---|
| | 139 | [regularImage compositeToPoint:NSMakePoint(0,0) operation:NSCompositeSourceOver]; //(12,0) |
|---|
| | 140 | [path moveToPoint:NSMakePoint(16, 1)]; |
|---|
| | 141 | [path lineToPoint:NSMakePoint(16. - cos(pi / 180. * (65. + cpuUsage)) * 16., sin(pi / 180. * (65. + cpuUsage)) * 29.)]; |
|---|
| | 142 | } else { |
|---|
| | 143 | [smallImage compositeToPoint:NSMakePoint(0,0) operation:NSCompositeSourceOver]; //(9,0) |
|---|
| | 144 | [path moveToPoint:NSMakePoint(12, 2)]; |
|---|
| | 145 | [path lineToPoint:NSMakePoint(12. - cos(pi / 180. * (65. + cpuUsage)) * 11., sin(pi / 180. * (65. + cpuUsage)) * 22.)]; |
|---|
| | 146 | } |
|---|
| | 147 | [path stroke]; |
|---|
| | 148 | |
|---|
| | 149 | |
|---|
| | 150 | /* Drive Activity Indicator */ |
|---|
| | 151 | BOOL DrivesAreActive = FALSE; |
|---|
| | 152 | BlockDriverState *bs; |
|---|
| | 153 | |
|---|
| | 154 | /* hda */ |
|---|
| | 155 | bs = bdrv_find([@"hda" cString]); |
|---|
| | 156 | if (bs) { |
|---|
| | 157 | if (bs->activityLED) { |
|---|
| | 158 | DrivesAreActive = YES; |
|---|
| | 159 | bs->activityLED = 0; |
|---|
| | 160 | } |
|---|
| | 161 | } |
|---|
| | 162 | |
|---|
| | 163 | /* CD-ROM */ |
|---|
| | 164 | bs = bdrv_find([@"cdrom" cString]); |
|---|
| | 165 | if (bs) { |
|---|
| | 166 | if (bs->activityLED) { |
|---|
| | 167 | DrivesAreActive = YES; |
|---|
| | 168 | bs->activityLED = 0; |
|---|
| | 169 | } |
|---|
| | 170 | } |
|---|
| | 171 | |
|---|
| | 172 | /* hdc */ |
|---|
| | 173 | bs = bdrv_find([@"hdc" cString]); |
|---|
| | 174 | if (bs) { |
|---|
| | 175 | if (bs->activityLED) { |
|---|
| | 176 | DrivesAreActive = YES; |
|---|
| | 177 | bs->activityLED = 0; |
|---|
| | 178 | } |
|---|
| | 179 | } |
|---|
| | 180 | |
|---|
| | 181 | /* hdd */ |
|---|
| | 182 | bs = bdrv_find([@"hdd" cString]); |
|---|
| | 183 | if (bs) { |
|---|
| | 184 | if (bs->activityLED) { |
|---|
| | 185 | DrivesAreActive = YES; |
|---|
| | 186 | bs->activityLED = 0; |
|---|
| | 187 | } |
|---|
| | 188 | } |
|---|
| | 189 | |
|---|
| | 190 | /* draw Indicator */ |
|---|
| | 191 | if (DrivesAreActive) { |
|---|
| | 192 | // [[NSColor yellowColor] setFill]; //E3BD00 //D9D401 |
|---|
| | 193 | [[NSColor colorWithDeviceRed:.89 green:.74 blue:.0 alpha:1.] setFill]; |
|---|
| | 194 | } else { |
|---|
| | 195 | [[NSColor blackColor] setFill]; |
|---|
| | 196 | } |
|---|
| | 197 | if( ctlSize == NSRegularControlSize ) { |
|---|
| | 198 | NSRectFill(NSMakeRect(3,2,26,2)); |
|---|
| | 199 | } else { |
|---|
| | 200 | NSRectFill(NSMakeRect(2,2,20,2)); |
|---|
| | 201 | } |
|---|
| 202 | 202 | } |
|---|
| 203 | 203 | |
|---|
| 204 | 204 | - (void) mouseDown:(NSEvent *) theEvent |
|---|
| 205 | 205 | { |
|---|
| 206 | | // NSLog(@"cocoaCpuView: mouseDown"); |
|---|
| | 206 | // NSLog(@"cocoaCpuView: mouseDown"); |
|---|
| 207 | 207 | |
|---|
| 208 | 208 | } |
|---|
| … | … | |
| 210 | 210 | - (NSControlSize) controlSize |
|---|
| 211 | 211 | { |
|---|
| 212 | | // NSLog(@"cocoaCpuView: controlSize"); |
|---|
| 213 | | |
|---|
| 214 | | return ( ctlSize ? ctlSize : NSRegularControlSize ); |
|---|
| | 212 | // NSLog(@"cocoaCpuView: controlSize"); |
|---|
| | 213 | |
|---|
| | 214 | return ( ctlSize ? ctlSize : NSRegularControlSize ); |
|---|
| 215 | 215 | } |
|---|
| 216 | 216 | |
|---|
| 217 | 217 | - (void) setControlSize:(NSControlSize) controlSize { |
|---|
| 218 | | if( controlSize == NSRegularControlSize ) { |
|---|
| 219 | | [toolbarItem setMinSize:NSMakeSize( 56., 32. )]; |
|---|
| 220 | | [toolbarItem setMaxSize:NSMakeSize( 56., 32. )]; |
|---|
| 221 | | } else if( controlSize == NSSmallControlSize ) { |
|---|
| 222 | | [toolbarItem setMinSize:NSMakeSize( 42., 24. )]; |
|---|
| 223 | | [toolbarItem setMaxSize:NSMakeSize( 42., 24. )]; |
|---|
| 224 | | } |
|---|
| 225 | | ctlSize = controlSize; |
|---|
| | 218 | if( controlSize == NSRegularControlSize ) { |
|---|
| | 219 | [toolbarItem setMinSize:NSMakeSize( 32., 32. )]; |
|---|
| | 220 | [toolbarItem setMaxSize:NSMakeSize( 32., 32. )]; |
|---|
| | 221 | } else if( controlSize == NSSmallControlSize ) { |
|---|
| | 222 | [toolbarItem setMinSize:NSMakeSize( 24., 24. )]; |
|---|
| | 223 | [toolbarItem setMaxSize:NSMakeSize( 24., 24. )]; |
|---|
| | 224 | } |
|---|
| | 225 | ctlSize = controlSize; |
|---|
| 226 | 226 | } |
|---|
| 227 | 227 | - (NSImage *) image; |
|---|
| 228 | 228 | { |
|---|
| 229 | | // NSLog(@"cocoaPopUpView: image"); |
|---|
| 230 | | |
|---|
| 231 | | return regularImage; |
|---|
| | 229 | // NSLog(@"cocoaPopUpView: image"); |
|---|
| | 230 | |
|---|
| | 231 | return regularImage; |
|---|
| 232 | 232 | } |
|---|
| 233 | 233 | |
|---|
| 234 | 234 | - (void) setImage:(NSImage *) image |
|---|
| 235 | 235 | { |
|---|
| 236 | | // NSLog(@"cocoaPopUpView: setImage"); |
|---|
| 237 | | |
|---|
| 238 | | int i; |
|---|
| 239 | | BOOL g = false; |
|---|
| 240 | | BOOL s = false; |
|---|
| 241 | | |
|---|
| 242 | | NSArray *reps = [image representations]; |
|---|
| 243 | | for (i=0; i<[reps count]; i++) { |
|---|
| 244 | | if ([[reps objectAtIndex:i] pixelsHigh] == 32) { |
|---|
| 245 | | [regularImage autorelease]; |
|---|
| 246 | | regularImage = [[NSImage alloc] initWithSize:NSMakeSize( 32., 32. )]; |
|---|
| 247 | | [regularImage addRepresentation:[reps objectAtIndex:i]]; |
|---|
| 248 | | g = true; |
|---|
| 249 | | } else if ([[reps objectAtIndex:i] pixelsHigh] == 24) { |
|---|
| 250 | | [smallImage autorelease]; |
|---|
| 251 | | smallImage = [[NSImage alloc] initWithSize:NSMakeSize( 24., 24. )]; |
|---|
| 252 | | [smallImage addRepresentation:[reps objectAtIndex:i]]; |
|---|
| 253 | | s = true; |
|---|
| 254 | | } |
|---|
| 255 | | } |
|---|
| 256 | | |
|---|
| 257 | | if (!g) { |
|---|
| 258 | | [regularImage autorelease]; |
|---|
| 259 | | regularImage = [image copy]; |
|---|
| 260 | | } |
|---|
| 261 | | |
|---|
| 262 | | if (!s) { |
|---|
| 263 | | NSImageRep *sourceImageRep = [image bestRepresentationForDevice:nil]; |
|---|
| 264 | | [smallImage autorelease]; |
|---|
| 265 | | smallImage = [[NSImage alloc] initWithSize:NSMakeSize( 24., 24. )]; |
|---|
| 266 | | [smallImage lockFocus]; |
|---|
| 267 | | [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh]; |
|---|
| 268 | | [sourceImageRep drawInRect:NSMakeRect( 0., 0., 24., 24. )]; |
|---|
| 269 | | [smallImage unlockFocus]; |
|---|
| 270 | | } |
|---|
| | 236 | // NSLog(@"cocoaPopUpView: setImage"); |
|---|
| | 237 | |
|---|
| | 238 | int i; |
|---|
| | 239 | BOOL g = false; |
|---|
| | 240 | BOOL s = false; |
|---|
| | 241 | |
|---|
| | 242 | NSArray *reps = [image representations]; |
|---|
| | 243 | for (i=0; i<[reps count]; i++) { |
|---|
| | 244 | if ([[reps objectAtIndex:i] pixelsHigh] == 32) { |
|---|
| | 245 | [regularImage autorelease]; |
|---|
| | 246 | regularImage = [[NSImage alloc] initWithSize:NSMakeSize( 32., 32. )]; |
|---|
| | 247 | [regularImage addRepresentation:[reps objectAtIndex:i]]; |
|---|
| | 248 | g = true; |
|---|
| | 249 | } else if ([[reps objectAtIndex:i] pixelsHigh] == 24) { |
|---|
| | 250 | [smallImage autorelease]; |
|---|
| | 251 | smallImage = [[NSImage alloc] initWithSize:NSMakeSize( 24., 24. )]; |
|---|
| | 252 | [smallImage addRepresentation:[reps objectAtIndex:i]]; |
|---|
| | 253 | s = true; |
|---|
| | 254 | } |
|---|
| | 255 | } |
|---|
| | 256 | |
|---|
| | 257 | if (!g) { |
|---|
| | 258 | [regularImage autorelease]; |
|---|
| | 259 | regularImage = [image copy]; |
|---|
| | 260 | } |
|---|
| | 261 | |
|---|
| | 262 | if (!s) { |
|---|
| | 263 | NSImageRep *sourceImageRep = [image bestRepresentationForDevice:nil]; |
|---|
| | 264 | [smallImage autorelease]; |
|---|
| | 265 | smallImage = [[NSImage alloc] initWithSize:NSMakeSize( 24., 24. )]; |
|---|
| | 266 | [smallImage lockFocus]; |
|---|
| | 267 | [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh]; |
|---|
| | 268 | [sourceImageRep drawInRect:NSMakeRect( 0., 0., 24., 24. )]; |
|---|
| | 269 | [smallImage unlockFocus]; |
|---|
| | 270 | } |
|---|
| 271 | 271 | } |
|---|
| 272 | 272 | |
|---|
| 273 | 273 | - (NSToolbarItem *) toolbarItem |
|---|
| 274 | 274 | { |
|---|
| 275 | | // NSLog(@"cocoaCpuView: toolbarItem"); |
|---|
| 276 | | |
|---|
| 277 | | return [[toolbarItem retain] autorelease]; |
|---|
| | 275 | // NSLog(@"cocoaCpuView: toolbarItem"); |
|---|
| | 276 | |
|---|
| | 277 | return [[toolbarItem retain] autorelease]; |
|---|
| 278 | 278 | } |
|---|
| 279 | 279 | |
|---|
| 280 | 280 | - (void) setToolbarItem:(NSToolbarItem *) item { |
|---|
| 281 | | toolbarItem = item; |
|---|
| | 281 | toolbarItem = item; |
|---|
| 282 | 282 | } |
|---|
| 283 | 283 | |
|---|
| 284 | 284 | - (void) updateToolbarItem:(NSTimer*) timer |
|---|
| 285 | 285 | { |
|---|
| 286 | | // NSLog(@"cocoaCpuView: updateToolbarItem"); |
|---|
| 287 | | |
|---|
| 288 | | [self setNeedsDisplay:YES]; |
|---|
| | 286 | // NSLog(@"cocoaCpuView: updateToolbarItem"); |
|---|
| | 287 | |
|---|
| | 288 | [self setNeedsDisplay:YES]; |
|---|
| 289 | 289 | } |
|---|
| 290 | 290 | @end |
|---|
| r83 |
r89 |
|
| 590 | 590 | return [NSArray arrayWithObjects: |
|---|
| 591 | 591 | @"newPCIdentifier", |
|---|
| 592 | | @"editPCIdentifier", |
|---|
| 593 | | @"startPCIdentifier", |
|---|
| 594 | | NSToolbarFlexibleSpaceItemIdentifier, |
|---|
| 595 | | // NSToolbarCustomizeToolbarItemIdentifier, |
|---|
| 596 | | @"removePCIdentifier", |
|---|
| | 592 | // @"editPCIdentifier", |
|---|
| | 593 | // @"startPCIdentifier", |
|---|
| | 594 | // NSToolbarFlexibleSpaceItemIdentifier, |
|---|
| | 595 | // NSToolbarCustomizeToolbarItemIdentifier, |
|---|
| | 596 | // @"removePCIdentifier", |
|---|
| 597 | 597 | nil]; |
|---|
| 598 | 598 | } |
|---|
Download in other formats:
| |