1
/*****************************************************************************
2
* sidebarview.m: MacOS X interface module
3
*****************************************************************************
4
* Copyright (C) 2005-2008 the VideoLAN team
5
* $Id: 2c1570b3d956b00a0f5a0007cd7610b1d0fb760b $
7
* Authors: Eric Dudiak <dudiak at gmail dot com>
8
* Colloquy <http://colloquy.info/>
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.
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.
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
*****************************************************************************/
25
#import "sidebarview.h"
29
@implementation sidebarview
30
- (void) resetCursorRects
32
if( ! [self isPaneSplitter] )
33
[super resetCursorRects];
36
- (id) initWithCoder:(NSCoder *) decoder {
37
if( ( self = [super initWithCoder:decoder] ) )
38
_mainSubviewIndex = 1;
42
- (CGFloat) dividerThickness
52
- (void) drawDividerInRect:(NSRect) rect
54
[[NSColor colorWithCalibratedWhite:0.65 alpha:1.] set];
58
- (void) adjustSubviews
60
if( _mainSubviewIndex == -1 || [[self subviews] count] != 2 ) {
61
[super adjustSubviews];
65
float dividerThickness = [self dividerThickness];
66
NSRect newFrame = [self frame];
68
NSView *mainView = [[self subviews] objectAtIndex:_mainSubviewIndex];
69
NSView *otherView = ( _mainSubviewIndex ? [[self subviews] objectAtIndex:0] : [[self subviews] objectAtIndex:1] );
71
NSRect mainFrame = [mainView frame];
72
NSRect otherFrame = [otherView frame];
75
mainFrame.size.width = NSWidth( newFrame ) - dividerThickness - NSWidth( otherFrame );
76
mainFrame.size.height = NSHeight( newFrame );
77
mainFrame.origin.x = ( _mainSubviewIndex ? NSWidth( otherFrame ) + dividerThickness : 0. );
78
mainFrame.origin.y = 0.;
80
otherFrame.size.width = NSWidth( otherFrame );
81
otherFrame.size.height = NSHeight( newFrame );
82
otherFrame.origin.x = ( _mainSubviewIndex ? 0. : NSWidth( mainFrame ) + dividerThickness );
83
otherFrame.origin.y = 0.;
85
[mainView setFrame:mainFrame];
86
[otherView setFrame:otherFrame];
88
[self setNeedsDisplay:YES];
92
/*****************************************************************************
93
* VLCPlaylist implementation
94
*****************************************************************************/
95
@implementation VLCSidebar
99
[o_outline_view setTarget: self];
100
[o_outline_view setDelegate: self];
101
[o_outline_view setDataSource: self];
102
[o_outline_view setAllowsEmptySelection: NO];
105
- (NSOutlineView *)outlineView
107
return o_outline_view;
110
- (void)outlineView:(NSOutlineView *)outlineView
111
willDisplayCell:(id)cell
112
forTableColumn:(NSTableColumn *)tableColumn
115
if ( ![outlineView isExpandable:item] )
117
[cell setFont: [NSFont systemFontOfSize: 12]];
118
[cell setTextColor:[NSColor blackColor]];
122
[cell setFont: [NSFont boldSystemFontOfSize: 10]];
123
[cell setTextColor:[NSColor colorWithCalibratedWhite:0.365 alpha:1.0]];
127
- (void)updateSidebar:(id)item
130
[o_outline_view reloadData];
131
i_row = [o_outline_view rowForItem:item];
134
[o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_row] byExtendingSelection:NO];
135
[o_outline_view scrollRowToVisible: i_row];
139
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
141
if( [outlineView isExpandable:item] )
147
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
149
if( [outlineView isExpandable:item] )
153
if( ![[o_playlist playingItem] isEqual: item] )
154
[o_playlist playSidebarItem:item];
159
- (void)outlineViewItemDidExpand:(NSNotification *)notification
162
i_row = [o_outline_view rowForItem:[o_playlist playingItem]];
165
[o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_row] byExtendingSelection:NO];
166
[o_outline_view scrollRowToVisible: i_row];
172
@implementation VLCSidebar (NSOutlineViewDataSource)
174
/* return the number of children for Obj-C pointer item */ /* DONE */
175
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
177
return [o_playlist outlineView:outlineView numberOfChildrenOfItem:item];
180
/* return the child at index for the Obj-C pointer item */ /* DONE */
181
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
183
return [o_playlist outlineView:outlineView child:index ofItem:item];
186
/* is the item expandable */
187
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
189
return [o_playlist outlineView:outlineView isItemExpandable:item];
192
/* retrieve the string values for the cells */
193
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
195
if( [outlineView isExpandable:item] )
196
return [[o_playlist outlineView:outlineView objectValueForTableColumn:o_tc byItem:item] uppercaseString];
198
return [o_playlist outlineView:outlineView objectValueForTableColumn:o_tc byItem:item];