]> git.sesse.net Git - vlc/blob - modules/gui/macosx_dialog_provider/VLCProgressPanel.m
Use var_InheritString for --decklink-video-connection.
[vlc] / modules / gui / macosx_dialog_provider / VLCProgressPanel.m
1 /*****************************************************************************
2  * VLCProgressPanel.m: A Generic Progress Indicator Panel created for VLC
3  *****************************************************************************
4  * Copyright (C) 2009-2010 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #import "VLCProgressPanel.h"
25
26
27 @implementation VLCProgressPanel
28
29 - (id)init
30 {
31     NSRect windowRect;
32     windowRect.size.height = 182;
33     windowRect.size.width = 520;
34     windowRect.origin.x = windowRect.origin.y = 0;
35
36     return [super initWithContentRect:windowRect
37                             styleMask:NSTitledWindowMask
38                               backing:NSBackingStoreBuffered
39                                 defer:YES];
40 }
41
42 - (void)createContentView
43 {
44     NSRect s_rc = [self frame];
45     id ourContentView = [self contentView];
46
47     s_rc.origin.x = 398;
48     s_rc.origin.y = 28;
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];
60
61     s_rc.origin.x = 89;
62     s_rc.origin.y = 153;
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];
72
73     s_rc.origin.x = 89;
74     s_rc.origin.y = 116;
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];
84
85     s_rc.origin.x = 90;
86     s_rc.origin.y = 66;
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];
98
99     s_rc.origin.x = 20;
100     s_rc.origin.y = 110;
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];
107 }
108
109 - setDialogTitle:(NSString *)title
110 {
111     [_titleField setStringValue:title];
112     [self setTitle:title];
113 }
114
115 - setDialogMessage:(NSString *)message
116 {
117     [_messageField setStringValue:message];
118 }
119
120 - setCancelButtonLabel:(NSString *)cancelLabel
121 {
122     [_cancelButton setTitle:cancelLabel];
123 }
124
125 - setProgressAsDouble:(double)value
126 {
127     [_progressBar setDoubleValue:value];
128 }
129
130 - (BOOL)isCancelled
131 {
132     return _isCancelled;
133 }
134
135 - (IBAction)cancelDialog:(id)sender
136 {
137     _isCancelled = YES;
138     [_progressBar setIndeterminate:YES];
139     [_progressBar startAnimation:self];
140 }
141
142 @end