1 /*****************************************************************************
2 * MainWindowTitle.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2011 Felix Paul Kühne
7 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #import <vlc_common.h>
26 #import "MainWindowTitle.h"
27 #import "CoreInteraction.h"
29 /*****************************************************************************
30 * VLCMainWindowTitleView
31 *****************************************************************************/
33 @implementation VLCMainWindowTitleView
37 [self setImageScaling: NSScaleToFit];
38 [self setImageFrameStyle: NSImageFrameNone];
39 [self setImageAlignment: NSImageAlignCenter];
40 [self setImage: [NSImage imageNamed:@"bottom-background_dark"]];
41 [self setAutoresizesSubviews: YES];
43 [o_red_btn setImage: [NSImage imageNamed:@"window-close"]];
44 [o_red_btn setAlternateImage: [NSImage imageNamed:@"window-close-on"]];
45 [[o_red_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
46 [o_yellow_btn setImage: [NSImage imageNamed:@"window-minimize"]];
47 [o_yellow_btn setAlternateImage: [NSImage imageNamed:@"window-minimize-on"]];
48 [[o_yellow_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
49 [o_green_btn setImage: [NSImage imageNamed:@"window-zoom"]];
50 [o_green_btn setAlternateImage: [NSImage imageNamed:@"window-zoom-on"]];
51 [[o_green_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
54 - (BOOL)mouseDownCanMoveWindow
59 - (IBAction)buttonAction:(id)sender
61 if (sender == o_red_btn)
62 [[self window] orderOut: sender];
63 else if (sender == o_yellow_btn)
64 [[self window] miniaturize: sender];
65 else if (sender == o_green_btn)
66 [[self window] performZoom: sender];
67 else if (sender == o_fullscreen_btn)
68 [[VLCCoreInteraction sharedInstance] toggleFullscreen];
70 msg_Err( VLCIntf, "unknown button action sender" );
73 - (void)setWindowTitle:(NSString *)title
75 [o_title_lbl setStringValue: title];
78 - (void)setFullscreenButtonHidden:(BOOL)b_value
80 [o_fullscreen_btn setHidden: b_value];
83 - (void)setWindowButtonOver:(BOOL)b_value
87 [o_red_btn setImage: [NSImage imageNamed:@"window-close-over"]];
88 [o_yellow_btn setImage: [NSImage imageNamed:@"window-minimize-over"]];
89 [o_green_btn setImage: [NSImage imageNamed:@"window-zoom-over"]];
93 [o_red_btn setImage: [NSImage imageNamed:@"window-close"]];
94 [o_yellow_btn setImage: [NSImage imageNamed:@"window-minimize"]];
95 [o_green_btn setImage: [NSImage imageNamed:@"window-zoom"]];
101 @implementation VLCWindowButtonCell
103 - (void)mouseEntered:(NSEvent *)theEvent
105 [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: YES];
108 - (void)mouseExited:(NSEvent *)theEvent
110 [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: NO];