1 /*****************************************************************************
2 * VLCProgressPanel.m: A Generic Progress Indicator Panel created for VLC
3 *****************************************************************************
4 * Copyright (C) 2009-2010 the VideoLAN team
7 * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #import "VLCProgressPanel.h"
27 @implementation VLCProgressPanel
32 windowRect.size.height = 182;
33 windowRect.size.width = 520;
34 windowRect.origin.x = windowRect.origin.y = 0;
36 return [super initWithContentRect:windowRect
37 styleMask:NSTitledWindowMask
38 backing:NSBackingStoreBuffered
42 - (void)createContentView
44 NSRect s_rc = [self frame];
45 id ourContentView = [self contentView];
49 s_rc.size.height = 32;
50 s_rc.size.width = 108;
51 _cancelButton = [[NSButton alloc] initWithFrame:s_rc];
52 [_cancelButton setButtonType:NSMomentaryLightButton];
53 [_cancelButton setTitle:@"Cancel"];
54 [_cancelButton setBezelStyle:NSRoundedBezelStyle];
55 [_cancelButton setBordered:YES];
56 [_cancelButton setTarget:self];
57 [_cancelButton setAction:@selector(cancelDialog:)];
58 [ourContentView addSubview:_cancelButton];
62 s_rc.size.height = 17;
63 s_rc.size.width = 414;
64 _titleField = [[NSTextField alloc] initWithFrame:s_rc];
65 [_titleField setFont:[NSFont boldSystemFontOfSize:0]];
66 [_titleField setBezeled:NO];
67 [_titleField setEditable:NO];
68 [_titleField setSelectable:YES];
69 [_titleField setDrawsBackground:NO];
70 [ourContentView addSubview:_titleField];
74 s_rc.size.height = 42;
75 s_rc.size.width = 414;
76 _messageField = [[NSTextField alloc] initWithFrame:s_rc];
77 [_messageField setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
78 [_messageField setBezeled:NO];
79 [_messageField setEditable:NO];
80 [_messageField setSelectable:YES];
81 [_messageField setDrawsBackground:NO];
82 [ourContentView addSubview:_messageField];
86 s_rc.size.height = 20;
87 s_rc.size.width = 412;
88 _progressBar = [[NSProgressIndicator alloc] initWithFrame:s_rc];
89 [_progressBar setMaxValue:1000.0];
90 [_progressBar setUsesThreadedAnimation:YES];
91 [_progressBar setStyle:NSProgressIndicatorBarStyle];
92 [_progressBar setDisplayedWhenStopped:YES];
93 [_progressBar setControlSize:NSRegularControlSize];
94 [_progressBar setIndeterminate:NO];
95 [ourContentView addSubview:_progressBar];
96 [_progressBar startAnimation:nil];
100 s_rc.size.height = s_rc.size.width = 64;
101 _iconView = [[NSImageView alloc] initWithFrame:s_rc];
102 [_iconView setImage:[NSImage imageNamed:@"NSApplicationIcon"]];
103 [_iconView setEditable:NO];
104 [_iconView setAllowsCutCopyPaste:NO];
105 [ourContentView addSubview:_iconView];
108 - setDialogTitle:(NSString *)title
110 [_titleField setStringValue:title];
111 [self setTitle:title];
114 - setDialogMessage:(NSString *)message
116 [_messageField setStringValue:message];
119 - setCancelButtonLabel:(NSString *)cancelLabel
121 [_cancelButton setTitle:cancelLabel];
124 - setProgressAsDouble:(double)value
126 [_progressBar setDoubleValue:value];
134 - (IBAction)cancelDialog:(id)sender