1 /*****************************************************************************
2 * misc.m: code not specific to vlc
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: misc.m,v 1.2 2003/03/13 22:24:17 hartman Exp $
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 #include <Cocoa/Cocoa.h>
28 /*****************************************************************************
29 * VLBrushedMetalImageView
30 *****************************************************************************/
32 @implementation VLBrushedMetalImageView
34 - (BOOL)mouseDownCanMoveWindow
42 /*****************************************************************************
44 *****************************************************************************/
46 @implementation MPSlider
50 return( [MPSliderCell class] );
55 /*****************************************************************************
57 *****************************************************************************/
59 @implementation MPSliderCell
67 _bgColor = [[NSColor colorWithDeviceRed: 0.8627451
71 _knobColor = [[NSColor blackColor] retain];
84 - (void)setBackgroundColor:(NSColor *)newColor
87 _bgColor = [newColor retain];
90 - (NSColor *)backgroundColor
95 - (void)setKnobColor:(NSColor *)newColor
98 _knobColor = [newColor retain];
101 - (NSColor *)knobColor
103 return( _knobColor );
106 - (void)setKnobThickness:(float)f_value
108 _knobThickness = f_value;
111 - (float)knobThickness
113 return( _knobThickness );
116 - (NSSize)cellSizeForBounds:(NSRect)s_rc
121 - (void)drawWithFrame:(NSRect)s_rc inView:(NSView *)o_view
123 if( _scFlags.weAreVertical )
125 s_rc.origin.x = 1; s_rc.size.width -= 3;
126 s_rc.origin.y = 2; s_rc.size.height -= 5;
130 s_rc.origin.x = 2; s_rc.size.width -= 5;
131 s_rc.origin.y = 1; s_rc.size.height -= 3;
134 [super drawWithFrame: s_rc inView: o_view];
137 - (void)drawBarInside:(NSRect)s_rc flipped:(BOOL)b_flipped
141 s_rc.size.width += (s_rc.origin.x * 2) + 1;
142 s_rc.size.height += (s_rc.origin.y * 2) + 1;
143 s_rc.origin.x = s_rc.origin.y = 0;
145 [[NSGraphicsContext currentContext] setShouldAntialias: NO];
151 s_arc.origin.x += 1.5;
152 s_arc.origin.y += 1.5;
153 s_arc.size.width -= s_arc.origin.x;
154 s_arc.size.height -= s_arc.origin.y;
155 [[_bgColor shadowWithLevel: 0.1] set];
156 [NSBezierPath strokeRect: s_arc];
158 s_arc.origin = s_rc.origin;
159 [[NSColor blackColor] set];
160 [NSBezierPath strokeRect: s_arc];
162 [[NSGraphicsContext currentContext] setShouldAntialias: YES];
165 - (NSRect)knobRectFlipped:(BOOL)b_flipped
171 floatValue = [self floatValue];
173 if( _scFlags.weAreVertical && b_flipped )
175 floatValue = _maxValue + _minValue - floatValue;
178 floatValue = (floatValue - _minValue) / (_maxValue - _minValue);
180 if( _scFlags.weAreVertical )
182 s_size = NSMakeSize( _trackRect.size.width, _knobThickness ?
183 _knobThickness : _trackRect.size.width );
184 s_pto = _trackRect.origin;
185 s_pto.y += (_trackRect.size.height - s_size.height) * floatValue;
189 s_size = NSMakeSize( _knobThickness ? _knobThickness :
190 _trackRect.size.height, _trackRect.size.height );
191 s_pto = _trackRect.origin;
192 s_pto.x += (_trackRect.size.width - s_size.width) * floatValue;
195 return NSMakeRect( s_pto.x, s_pto.y, s_size.width, s_size.height );
198 - (void)drawKnob:(NSRect)s_rc
200 [[NSGraphicsContext currentContext] setShouldAntialias: NO];
205 [[NSGraphicsContext currentContext] setShouldAntialias: YES];