]> git.sesse.net Git - vlc/blob - modules/gui/macosx/misc.h
macosx: fix resume playback guards, do not resume for folder urls
[vlc] / modules / gui / macosx / misc.h
1 /*****************************************************************************
2  * misc.h: code not specific to vlc
3  *****************************************************************************
4  * Copyright (C) 2003-2014 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8  *          Felix Paul Kühne <fkuehne at videolan dot org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #import <Cocoa/Cocoa.h>
26
27 /*****************************************************************************
28  * NSSound (VLCAdditions)
29  *
30  * added code to change the system volume, needed for the apple remote code
31  * this is simplified code, which won't let you set the exact volume
32  * (that's what the audio output is for after all), but just the system volume
33  * in steps of 1/16 (matching the default AR or volume key implementation).
34  *****************************************************************************/
35
36 @interface NSSound (VLCAdditions)
37 + (float)systemVolumeForChannel:(int)channel;
38 + (bool)setSystemVolume:(float)volume forChannel:(int)channel;
39 + (void)increaseSystemVolume;
40 + (void)decreaseSystemVolume;
41 @end
42
43 /*****************************************************************************
44  * NSAnimation (VLCAddition)
45  *****************************************************************************/
46
47 @interface NSAnimation (VLCAdditions)
48 @property (readwrite) void * userInfo;
49
50 @end
51
52 /*****************************************************************************
53  * NSScreen (VLCAdditions)
54  *
55  *  Missing extension to NSScreen
56  *****************************************************************************/
57
58 @interface NSScreen (VLCAdditions)
59
60 + (NSScreen *)screenWithDisplayID: (CGDirectDisplayID)displayID;
61 - (BOOL)hasMenuBar;
62 - (BOOL)hasDock;
63 - (BOOL)isScreen: (NSScreen*)screen;
64 - (CGDirectDisplayID)displayID;
65 - (void)blackoutOtherScreens;
66 + (void)unblackoutScreens;
67
68 - (void)setFullscreenPresentationOptions;
69 - (void)setNonFullscreenPresentationOptions;
70 @end
71
72 /*****************************************************************************
73  * VLCDragDropView
74  *
75  * Disables default drag / drop behaviour of an NSImageView.
76  * set it for all sub image views withing an VLCDragDropView.
77  *****************************************************************************/
78
79
80 @interface VLCDropDisabledImageView : NSImageView
81
82 @end
83
84 /*****************************************************************************
85  * VLCDragDropView
86  *****************************************************************************/
87
88 @interface VLCDragDropView : NSView
89 {
90     bool b_activeDragAndDrop;
91
92     id _dropHandler;
93 }
94
95 @property (nonatomic, assign) id dropHandler;
96 @property (nonatomic, assign) BOOL drawBorder;
97
98
99 - (void)enablePlaylistItems;
100
101 @end
102
103
104 /*****************************************************************************
105  * MPSlider
106  *****************************************************************************/
107
108 @interface MPSlider : NSSlider
109
110 @end
111
112 /*****************************************************************************
113  * ProgressView
114  *****************************************************************************/
115
116 @interface VLCProgressView : NSView
117
118 - (void)scrollWheel:(NSEvent *)o_event;
119
120 @end
121
122
123 /*****************************************************************************
124  * TimeLineSlider
125  *****************************************************************************/
126
127 @interface TimeLineSlider : NSSlider
128 {
129     NSImage *o_knob_img;
130     NSRect img_rect;
131     BOOL b_dark;
132 }
133 @property (readonly) CGFloat knobPosition;
134
135 - (void)drawRect:(NSRect)rect;
136 - (void)drawKnobInRect:(NSRect)knobRect;
137
138 @end
139
140 /*****************************************************************************
141  * VLCVolumeSliderCommon
142  *****************************************************************************/
143
144 @interface VLCVolumeSliderCommon : NSSlider
145 {
146     BOOL _usesBrightArtwork;
147 }
148 @property (readwrite, nonatomic) BOOL usesBrightArtwork;
149
150 - (void)scrollWheel:(NSEvent *)o_event;
151 - (void)drawFullVolumeMarker;
152
153 - (CGFloat)fullVolumePos;
154
155 @end
156
157 @interface VolumeSliderCell : NSSliderCell
158 @end
159
160 /*****************************************************************************
161  * ITSlider
162  *****************************************************************************/
163
164 @interface ITSlider : VLCVolumeSliderCommon
165 {
166     NSImage *img;
167     NSRect image_rect;
168 }
169
170 - (void)drawRect:(NSRect)rect;
171 - (void)drawKnobInRect:(NSRect)knobRect;
172
173 @end
174
175 /*****************************************************************************
176  * VLCTimeField interface
177  *****************************************************************************
178  * we need the implementation to catch our click-event in the controller window
179  *****************************************************************************/
180
181 @interface VLCTimeField : NSTextField
182 {
183     NSShadow * o_string_shadow;
184     NSTextAlignment textAlignment;
185
186     NSString *o_remaining_identifier;
187     BOOL b_time_remaining;
188 }
189 @property (readonly) BOOL timeRemaining;
190
191 -(id)initWithFrame:(NSRect)frameRect;
192
193 - (void)setRemainingIdentifier:(NSString *)o_string;
194
195 @end
196
197 /*****************************************************************************
198  * VLCMainWindowSplitView interface
199  *****************************************************************************/
200 @interface VLCMainWindowSplitView : NSSplitView
201
202 @end
203
204 /*****************************************************************************
205  * VLCThreePartImageView interface
206  *****************************************************************************/
207 @interface VLCThreePartImageView : NSView
208 {
209     NSImage * o_left_img;
210     NSImage * o_middle_img;
211     NSImage * o_right_img;
212 }
213
214 - (void)setImagesLeft:(NSImage *)left middle: (NSImage *)middle right:(NSImage *)right;
215 @end
216
217
218 /*****************************************************************************
219  * PositionFormatter interface
220  *
221  * Formats a text field to only accept decimals and :
222  *****************************************************************************/
223 @interface PositionFormatter : NSFormatter
224 {
225     NSCharacterSet *o_forbidden_characters;
226 }
227 - (NSString*)stringForObjectValue:(id)obj;
228
229 - (BOOL)getObjectValue:(id*)obj forString:(NSString*)string errorDescription:(NSString**)error;
230
231 - (BOOL)isPartialStringValid:(NSString*)partialString newEditingString:(NSString**)newString errorDescription:(NSString**)error;
232
233 @end
234
235 /*****************************************************************************
236  * NSView addition
237  *****************************************************************************/
238
239 @interface NSView (EnableSubviews)
240 - (void)enableSubviews:(BOOL)b_enable;
241 @end
242
243 /*****************************************************************************
244  * VLCByteCountFormatter addition
245  *****************************************************************************/
246
247 #ifndef MAC_OS_X_VERSION_10_8
248 enum {
249     // Specifies display of file or storage byte counts. The actual behavior for this is platform-specific; on OS X 10.7 and less, this uses the binary style, but decimal style on 10.8 and above
250     NSByteCountFormatterCountStyleFile   = 0,
251     // Specifies display of memory byte counts. The actual behavior for this is platform-specific; on OS X 10.7 and less, this uses the binary style, but that may change over time.
252     NSByteCountFormatterCountStyleMemory = 1,
253     // The following two allow specifying the number of bytes for KB explicitly. It's better to use one of the above values in most cases.
254     NSByteCountFormatterCountStyleDecimal = 2,    // 1000 bytes are shown as 1 KB
255     NSByteCountFormatterCountStyleBinary  = 3     // 1024 bytes are shown as 1 KB
256 };
257 typedef NSInteger NSByteCountFormatterCountStyle;
258 #endif
259
260 @interface VLCByteCountFormatter : NSFormatter {
261 }
262
263 + (NSString *)stringFromByteCount:(long long)byteCount countStyle:(NSByteCountFormatterCountStyle)countStyle;
264 @end