00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <Cocoa/Cocoa.h>
00025
00026 #include "intf.h"
00027 #include "misc.h"
00028 #include "playlist.h"
00029
00030
00031
00032
00033
00034 @implementation VLCControllerWindow
00035
00036 - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask
00037 backing:(NSBackingStoreType)backingType defer:(BOOL)flag
00038 {
00039 self = [super initWithContentRect:contentRect styleMask:styleMask
00040 backing:backingType defer:flag];
00041
00042 [[VLCMain sharedInstance] updateTogglePlaylistState];
00043
00044 return( self );
00045 }
00046
00047 - (BOOL)performKeyEquivalent:(NSEvent *)o_event
00048 {
00049 return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event];
00050 }
00051
00052 @end
00053
00054
00055
00056
00057
00058
00059
00060 @implementation VLCControllerView
00061
00062 - (void)dealloc
00063 {
00064 [self unregisterDraggedTypes];
00065 [super dealloc];
00066 }
00067
00068 - (void)awakeFromNib
00069 {
00070 [self registerForDraggedTypes:[NSArray arrayWithObjects:NSTIFFPboardType,
00071 NSFilenamesPboardType, nil]];
00072 }
00073
00074 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
00075 {
00076 if ((NSDragOperationGeneric & [sender draggingSourceOperationMask])
00077 == NSDragOperationGeneric)
00078 {
00079 return NSDragOperationGeneric;
00080 }
00081 else
00082 {
00083 return NSDragOperationNone;
00084 }
00085 }
00086
00087 - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
00088 {
00089 return YES;
00090 }
00091
00092 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
00093 {
00094 NSPasteboard *o_paste = [sender draggingPasteboard];
00095 NSArray *o_types = [NSArray arrayWithObjects: NSFilenamesPboardType, nil];
00096 NSString *o_desired_type = [o_paste availableTypeFromArray:o_types];
00097 NSData *o_carried_data = [o_paste dataForType:o_desired_type];
00098
00099 if( o_carried_data )
00100 {
00101 if ([o_desired_type isEqualToString:NSFilenamesPboardType])
00102 {
00103 int i;
00104 NSArray *o_array = [NSArray array];
00105 NSArray *o_values = [[o_paste propertyListForType: NSFilenamesPboardType]
00106 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
00107
00108 for( i = 0; i < (int)[o_values count]; i++)
00109 {
00110 NSDictionary *o_dic;
00111 o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"];
00112 o_array = [o_array arrayByAddingObject: o_dic];
00113 }
00114 [(VLCPlaylist *)[[VLCMain sharedInstance] getPlaylist] appendArray: o_array atPos: -1 enqueue:NO];
00115 return YES;
00116 }
00117 }
00118 [self setNeedsDisplay:YES];
00119 return YES;
00120 }
00121
00122 - (void)concludeDragOperation:(id <NSDraggingInfo>)sender
00123 {
00124 [self setNeedsDisplay:YES];
00125 }
00126
00127 @end
00128
00129
00130
00131
00132
00133 @implementation VLBrushedMetalImageView
00134
00135 - (BOOL)mouseDownCanMoveWindow
00136 {
00137 return YES;
00138 }
00139
00140 - (void)dealloc
00141 {
00142 [self unregisterDraggedTypes];
00143 [super dealloc];
00144 }
00145
00146 - (void)awakeFromNib
00147 {
00148 [self registerForDraggedTypes:[NSArray arrayWithObjects:NSTIFFPboardType,
00149 NSFilenamesPboardType, nil]];
00150 }
00151
00152 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
00153 {
00154 if ((NSDragOperationGeneric & [sender draggingSourceOperationMask])
00155 == NSDragOperationGeneric)
00156 {
00157 return NSDragOperationGeneric;
00158 }
00159 else
00160 {
00161 return NSDragOperationNone;
00162 }
00163 }
00164
00165 - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
00166 {
00167 return YES;
00168 }
00169
00170 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
00171 {
00172 NSPasteboard *o_paste = [sender draggingPasteboard];
00173 NSArray *o_types = [NSArray arrayWithObjects: NSFilenamesPboardType, nil];
00174 NSString *o_desired_type = [o_paste availableTypeFromArray:o_types];
00175 NSData *o_carried_data = [o_paste dataForType:o_desired_type];
00176
00177 if( o_carried_data )
00178 {
00179 if ([o_desired_type isEqualToString:NSFilenamesPboardType])
00180 {
00181 int i;
00182 NSArray *o_array = [NSArray array];
00183 NSArray *o_values = [[o_paste propertyListForType: NSFilenamesPboardType]
00184 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
00185
00186 for( i = 0; i < (int)[o_values count]; i++)
00187 {
00188 NSDictionary *o_dic;
00189 o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"];
00190 o_array = [o_array arrayByAddingObject: o_dic];
00191 }
00192 [[[VLCMain sharedInstance] getPlaylist] appendArray: o_array atPos: -1 enqueue:NO];
00193 return YES;
00194 }
00195 }
00196 [self setNeedsDisplay:YES];
00197 return YES;
00198 }
00199
00200 - (void)concludeDragOperation:(id <NSDraggingInfo>)sender
00201 {
00202 [self setNeedsDisplay:YES];
00203 }
00204
00205 @end
00206
00207
00208
00209
00210
00211 @implementation MPSlider
00212
00213 void _drawKnobInRect(NSRect knobRect)
00214 {
00215
00216 knobRect.origin.x += (int)((float)(knobRect.size.width - 7)/2.0);
00217 knobRect.origin.y += (int)((float)(knobRect.size.height - 7)/2.0);
00218
00219
00220 NSRectFillUsingOperation(NSMakeRect(knobRect.origin.x + 3, knobRect.origin.y + 6, 1, 1), NSCompositeSourceOver);
00221 NSRectFillUsingOperation(NSMakeRect(knobRect.origin.x + 2, knobRect.origin.y + 5, 3, 1), NSCompositeSourceOver);
00222 NSRectFillUsingOperation(NSMakeRect(knobRect.origin.x + 1, knobRect.origin.y + 4, 5, 1), NSCompositeSourceOver);
00223 NSRectFillUsingOperation(NSMakeRect(knobRect.origin.x + 0, knobRect.origin.y + 3, 7, 1), NSCompositeSourceOver);
00224 NSRectFillUsingOperation(NSMakeRect(knobRect.origin.x + 1, knobRect.origin.y + 2, 5, 1), NSCompositeSourceOver);
00225 NSRectFillUsingOperation(NSMakeRect(knobRect.origin.x + 2, knobRect.origin.y + 1, 3, 1), NSCompositeSourceOver);
00226 NSRectFillUsingOperation(NSMakeRect(knobRect.origin.x + 3, knobRect.origin.y + 0, 1, 1), NSCompositeSourceOver);
00227 }
00228
00229 void _drawFrameInRect(NSRect frameRect)
00230 {
00231
00232 NSRectFillUsingOperation(NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width, 1), NSCompositeSourceOver);
00233 NSRectFillUsingOperation(NSMakeRect(frameRect.origin.x, frameRect.origin.y + frameRect.size.height-1, frameRect.size.width, 1), NSCompositeSourceOver);
00234 NSRectFillUsingOperation(NSMakeRect(frameRect.origin.x, frameRect.origin.y, 1, frameRect.size.height), NSCompositeSourceOver);
00235 NSRectFillUsingOperation(NSMakeRect(frameRect.origin.x+frameRect.size.width-1, frameRect.origin.y, 1, frameRect.size.height), NSCompositeSourceOver);
00236 }
00237
00238 - (void)drawRect:(NSRect)rect
00239 {
00240
00241 [[NSGraphicsContext currentContext] saveGraphicsState];
00242 NSRectClip(NSZeroRect);
00243 [super drawRect:rect];
00244 [[NSGraphicsContext currentContext] restoreGraphicsState];
00245
00246
00247 rect = [self bounds];
00248 int diff = (int)(([[self cell] knobThickness] - 7.0)/2.0) - 1;
00249 rect.origin.x += diff-1;
00250 rect.origin.y += diff;
00251 rect.size.width -= 2*diff-2;
00252 rect.size.height -= 2*diff;
00253
00254
00255 NSRect knobRect = [[self cell] knobRectFlipped:NO];
00256 [[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
00257 _drawFrameInRect(rect);
00258 _drawKnobInRect(knobRect);
00259
00260
00261 [[[NSColor blackColor] colorWithAlphaComponent:0.1] set];
00262 rect.origin.x++;
00263 rect.origin.y++;
00264 knobRect.origin.x++;
00265 knobRect.origin.y++;
00266 _drawFrameInRect(rect);
00267 _drawKnobInRect(knobRect);
00268 }
00269
00270 @end
00271
00272
00273
00274
00275
00276
00277 @implementation ITSlider
00278
00279 - (void)awakeFromNib
00280 {
00281 if ([[self cell] class] != [ITSliderCell class]) {
00282
00283 NSSliderCell *oldCell = [self cell];
00284 NSSliderCell *newCell = [[[ITSliderCell alloc] init] autorelease];
00285 [newCell setTag:[oldCell tag]];
00286 [newCell setTarget:[oldCell target]];
00287 [newCell setAction:[oldCell action]];
00288 [newCell setControlSize:[oldCell controlSize]];
00289 [newCell setType:[oldCell type]];
00290 [newCell setState:[oldCell state]];
00291 [newCell setAllowsTickMarkValuesOnly:[oldCell allowsTickMarkValuesOnly]];
00292 [newCell setAltIncrementValue:[oldCell altIncrementValue]];
00293 [newCell setControlTint:[oldCell controlTint]];
00294 [newCell setKnobThickness:[oldCell knobThickness]];
00295 [newCell setMaxValue:[oldCell maxValue]];
00296 [newCell setMinValue:[oldCell minValue]];
00297 [newCell setDoubleValue:[oldCell doubleValue]];
00298 [newCell setNumberOfTickMarks:[oldCell numberOfTickMarks]];
00299 [newCell setEditable:[oldCell isEditable]];
00300 [newCell setEnabled:[oldCell isEnabled]];
00301 [newCell setEntryType:[oldCell entryType]];
00302 [newCell setHighlighted:[oldCell isHighlighted]];
00303 [newCell setTickMarkPosition:[oldCell tickMarkPosition]];
00304 [self setCell:newCell];
00305 }
00306 }
00307
00308 @end
00309
00310
00311
00312
00313 @implementation ITSliderCell
00314
00315 - (id)init
00316 {
00317 self = [super init];
00318 _knobOff = [[NSImage imageNamed:@"volumeslider_normal"] retain];
00319 _knobOn = [[NSImage imageNamed:@"volumeslider_blue"] retain];
00320 b_mouse_down = FALSE;
00321 return self;
00322 }
00323
00324 - (void)dealloc
00325 {
00326 [_knobOff release];
00327 [_knobOn release];
00328 [super dealloc];
00329 }
00330
00331 - (void)drawKnob:(NSRect)knob_rect
00332 {
00333 NSImage *knob;
00334
00335 if( b_mouse_down )
00336 knob = _knobOn;
00337 else
00338 knob = _knobOff;
00339
00340 [[self controlView] lockFocus];
00341 [knob compositeToPoint:NSMakePoint( knob_rect.origin.x + 1,
00342 knob_rect.origin.y + knob_rect.size.height -2 )
00343 operation:NSCompositeSourceOver];
00344 [[self controlView] unlockFocus];
00345 }
00346
00347 - (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:
00348 (NSView *)controlView mouseIsUp:(BOOL)flag
00349 {
00350 b_mouse_down = NO;
00351 [self drawKnob];
00352 [super stopTracking:lastPoint at:stopPoint inView:controlView mouseIsUp:flag];
00353 }
00354
00355 - (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView
00356 {
00357 b_mouse_down = YES;
00358 [self drawKnob];
00359 return [super startTrackingAt:startPoint inView:controlView];
00360 }
00361
00362 @end
00363