Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 119 lines (86 sloc) 2.266 kb
dc5be1c Initial check-in.
uli authored
1 //
2 // UKDockProgressIndicator.m
3 // Doublette
4 //
5 // Created by Uli Kusterer on 30.04.05.
6 // Copyright 2005 M. Uli Kusterer. All rights reserved.
7 //
8
9 #import "UKDockProgressIndicator.h"
10
11
12 @implementation UKDockProgressIndicator
13
14 -(void) setMinValue: (double)mn
15 {
16 min = mn;
17 [progress setMinValue: mn];
18
19 [self updateDockTile];
20 }
21
22 -(double) minValue
23 {
24 return min;
25 }
26
27
28 -(void) setMaxValue: (double)mn
29 {
30 max = mn;
31 [progress setMaxValue: mn];
32
33 [self updateDockTile];
34 }
35
36 -(double) maxValue
37 {
38 return max;
39 }
40
41
42 -(void) setDoubleValue: (double)mn
43 {
44 current = mn;
45 [progress setDoubleValue: mn];
46 [self updateDockTile];
47 }
48
49 -(double) doubleValue
50 {
51 return current;
52 }
53
54
55 -(void) setNeedsDisplay: (BOOL)mn
56 {
57 [progress setNeedsDisplay: mn];
58 }
59
60
61 -(void) display
62 {
63 [progress display];
64 }
65
66
67 -(void) setHidden: (BOOL)flag
68 {
69 [progress setHidden: flag];
70 if( flag ) // Progress indicator is being hidden? Reset dock tile to regular icon again:
71 [NSApp setApplicationIconImage: [NSImage imageNamed: @"NSApplicationIcon"]];
72 }
73
74 -(BOOL) isHidden
75 {
76 return [progress isHidden];
77 }
78
79
80 -(void) updateDockTile
81 {
82 NSImage* dockIcon = [[[NSImage alloc] initWithSize: NSMakeSize(128,128)] autorelease];
83
84
85 [dockIcon lockFocus];
86 NSRect box = { {4, 4}, {120, 16} };
87
88 // App icon:
89 [[NSImage imageNamed: @"NSApplicationIcon"] dissolveToPoint: NSZeroPoint fraction: 1.0];
90
91 // Track & Outline:
92 [[NSColor whiteColor] set];
93 [NSBezierPath fillRect: box];
94
95 [[NSColor blackColor] set];
96 [NSBezierPath strokeRect: box];
97
98 // State fill:
99 box = NSInsetRect( box, 1, 1 );
100 [[NSColor knobColor] set];
101
102 box.size.width = (box.size.width / (max -min)) * (current -min);
103
104 NSImage* prImg = [NSImage imageNamed: @"MiniProgressGradient"];
105 NSRect picBox = { { 0,0 }, { 0,0 } };
106 if( prImg )
107 {
108 picBox.size = [prImg size];
109 [prImg drawInRect: box fromRect: picBox operation: NSCompositeCopy fraction: 1.0];
110 }
111 else
112 NSRectFill( box );
113 [dockIcon unlockFocus];
114
115 [NSApp setApplicationIconImage: dockIcon];
116 }
117
118 @end
Something went wrong with that request. Please try again.