-
Notifications
You must be signed in to change notification settings - Fork 17
/
progressIndicator.m
106 lines (94 loc) · 3.88 KB
/
progressIndicator.m
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
#import "progressIndicator.h"
#include "_cgo_export.h"
ProgressIndicatorPtr ProgressIndicator_New(int x, int y, int width, int height) {
id nsProgressIndicator = [[NSProgressIndicator alloc] init];
[nsProgressIndicator setFrame: NSMakeRect(x, y, width, height)];
//[nsProgressIndicator setBounds: NSMakeRect(x, y, width, height)];
[nsProgressIndicator setUsesThreadedAnimation:YES];
[nsProgressIndicator autorelease];
return (ProgressIndicatorPtr)nsProgressIndicator;
}
void ProgressIndicator_StartAnimation(ProgressIndicatorPtr progressIndicatorPtr)
{
dispatch_async(dispatch_get_main_queue(), ^{
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
[progressIndicator startAnimation:nil];
[progressIndicator setNeedsDisplay:YES];
});
}
void ProgressIndicator_StopAnimation(ProgressIndicatorPtr progressIndicatorPtr)
{
dispatch_async(dispatch_get_main_queue(), ^{
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
[progressIndicator stopAnimation:nil];
[progressIndicator setNeedsDisplay:YES];
});
}
void ProgressIndicator_SetLimits(ProgressIndicatorPtr progressIndicatorPtr, double minValue, double maxValue)
{
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
[progressIndicator setMinValue:minValue];
[progressIndicator setMaxValue:maxValue];
}
void ProgressIndicator_SetValue(ProgressIndicatorPtr progressIndicatorPtr, double value)
{
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
dispatch_async(dispatch_get_main_queue(), ^{
[progressIndicator setDoubleValue:value];
NSLog(@"progressIndicator value is %.2f", value);
[progressIndicator setNeedsDisplay:YES];
});
}
void ProgressIndicator_IncrementBy(ProgressIndicatorPtr progressIndicatorPtr, double value)
{
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
dispatch_async(dispatch_get_main_queue(), ^{
[progressIndicator incrementBy:value];
NSLog(@"increasing progressIndicator value by %.2f", value);
[progressIndicator setNeedsDisplay:YES];
});
}
void ProgressIndicator_SetIsIndeterminate(ProgressIndicatorPtr progressIndicatorPtr, int value)
{
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
if(value > 0) {
[progressIndicator setIndeterminate: YES];
} else {
[progressIndicator setIndeterminate: NO];
}
}
int ProgressIndicator_IsIndeterminate(ProgressIndicatorPtr progressIndicatorPtr)
{
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
if ([progressIndicator isIndeterminate]) {
return 1;
}
return 0;
}
void ProgressIndicator_SetDisplayedWhenStopped(ProgressIndicatorPtr progressIndicatorPtr, int value) {
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
if(value > 0) {
[progressIndicator setDisplayedWhenStopped: YES];
} else {
[progressIndicator setDisplayedWhenStopped: NO];
}
}
void ProgressIndicator_Show(ProgressIndicatorPtr progressIndicatorPtr)
{
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
dispatch_async(dispatch_get_main_queue(), ^{
progressIndicator.hidden = NO;
});
}
void ProgressIndicator_Hide(ProgressIndicatorPtr progressIndicatorPtr){
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
[NSThread sleepForTimeInterval:1.0];
dispatch_async(dispatch_get_main_queue(), ^{
progressIndicator.hidden = YES;
});
}
void ProgressIndicator_Remove(ProgressIndicatorPtr progressIndicatorPtr)
{
NSProgressIndicator* progressIndicator = (NSProgressIndicator*)progressIndicatorPtr;
[progressIndicator removeFromSuperview];
}