1 /*****************************************************************************
2 * VLCProgressPanel.m: A Generic Progress Indicator Panel created for VLC
3 *****************************************************************************
4 * Copyright (C) 2009-2010 VLC authors and VideoLAN
7 * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * 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 [_cancelButton setKeyEquivalent:@"\e"] ; // escape key
59 [ourContentView addSubview:_cancelButton];
63 s_rc.size.height = 17;
64 s_rc.size.width = 414;
65 _titleField = [[NSTextField alloc] initWithFrame:s_rc];
66 [_titleField setFont:[NSFont boldSystemFontOfSize:0]];
67 [_titleField setBezeled:NO];
68 [_titleField setEditable:NO];
69 [_titleField setSelectable:YES];
70 [_titleField setDrawsBackground:NO];
71 [ourContentView addSubview:_titleField];
75 s_rc.size.height = 42;
76 s_rc.size.width = 414;
77 _messageField = [[NSTextField alloc] initWithFrame:s_rc];
78 [_messageField setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
79 [_messageField setBezeled:NO];
80 [_messageField setEditable:NO];
81 [_messageField setSelectable:YES];
82 [_messageField setDrawsBackground:NO];
83 [ourContentView addSubview:_messageField];
87 s_rc.size.height = 20;
88 s_rc.size.width = 412;
89 _progressBar = [[NSProgressIndicator alloc] initWithFrame:s_rc];
90 [_progressBar setMaxValue:1000.0];
91 [_progressBar setUsesThreadedAnimation:YES];
92 [_progressBar setStyle:NSProgressIndicatorBarStyle];
93 [_progressBar setDisplayedWhenStopped:YES];
94 [_progressBar setControlSize:NSRegularControlSize];
95 [_progressBar setIndeterminate:NO];
96 [ourContentView addSubview:_progressBar];
97 [_progressBar startAnimation:nil];
101 s_rc.size.height = s_rc.size.width = 64;
102 _iconView = [[NSImageView alloc] initWithFrame:s_rc];
103 [_iconView setImage:[NSImage imageNamed:@"NSApplicationIcon"]];
104 [_iconView setEditable:NO];
105 [_iconView setAllowsCutCopyPaste:NO];
106 [ourContentView addSubview:_iconView];
109 - (void)setDialogTitle:(NSString *)title
111 [_titleField setStringValue:title];
112 [self setTitle:title];
115 - (void)setDialogMessage:(NSString *)message
117 [_messageField setStringValue:message];
120 - (void)setCancelButtonLabel:(NSString *)cancelLabel
122 [_cancelButton setTitle:cancelLabel];
125 - (void)setProgressAsDouble:(double)value
127 [_progressBar setDoubleValue:value];
135 - (IBAction)cancelDialog:(id)sender
138 [_progressBar setIndeterminate:YES];
139 [_progressBar startAnimation:self];