-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBCProgressDialog.h
106 lines (64 loc) · 2.47 KB
/
BCProgressDialog.h
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
//
// BCProgressDialog.h
//
// Created by Tom Houpt on 11/4/30.
// Copyright 2011 "Voyages". All rights reserved.
//
#import <Cocoa/Cocoa.h>
// timer periods
#define kProgressCheckInterval kAlpha05
/*
Displays a dialog box with 2 progress bars and a cancel button
a title label, e.g. "Cell Counting Across Images"
a top label, e.g. "Processing Image 7 of 20"
top progress bar with value from 0.0 to 100.0, e.g. 100 * (7/20)
a sublabel, e.g. "Scanning line 300 of 640"
sub progress bar with value from 0.0 to 100.0, e.g. 100* (300/640)
USAGE:
// make sure "BCProgressDialog.nib" is part of the project
BCProgressDialog *progress = [[BCProgressDialog alloc] init];
NSString *progressTitle = @"Cell Counting Across Images";
[progress setTitleLabel:progressTitle];
[progress startDisplayForWindow:[myNSDocument windowForSheet]];
// if you only want 1 progress bar, call:
// [progress hideSubLabelAndIndicator];
for (image = 1; image <=20; image++) {
// top indicator
NSString *topLabel = [NSString stringWithFormat:@"Processing image %d of 20", image];
[progress setTopLabel:topLabel andTopIndicator:100*image/20;
for (line = 1; line <= 640; line++) {
// subindicator
NSString *subLabel = [NSString stringWithFormat:@"Scanning line %d of 640", line];
[progress subLabel andSubIndicator:100*line/640;
// was cancel button pressed?
if ([progress cancelWasPressed]) {
[progress endDisplay];
// process cancelation
}
} // next line (subindicator)
} next image (topindicator)
[progress endDisplay];
*/
@interface BCProgressDialog : NSObject {
IBOutlet NSPanel *dialog;
IBOutlet NSTextField *title;
IBOutlet NSTextField *topLabel;
IBOutlet NSTextField *subLabel;
IBOutlet NSProgressIndicator *topIndicator;
IBOutlet NSProgressIndicator *subIndicator;
IBOutlet NSImageView *iconImageView;
IBOutlet NSButton *cancelButton;
BOOL cancelWasPressed;
// NSTimer * _progressTimer; // timer for updating the progress dialog box
}
-(id)init;
-(void)startDisplayForWindow:(NSWindow *)ownerWindow;
-(void)endDisplay;
-(void)setIconImage:(NSImage *)theImage;
-(void)setTitleLabel:(NSString *)text;
-(void)setTopLabel:(NSString *)top andTopIndicator:(double)value;
-(void)setSubLabel:(NSString *)sub andSubIndicator:(double)value;
-(void)hideSubLabelAndIndicator;
-(IBAction)cancelButtonPressed:(id)sender;
-(BOOL)cancelWasPressed;
@end